liyaengine 0.5.0__tar.gz → 0.6.0__tar.gz
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.
- {liyaengine-0.5.0 → liyaengine-0.6.0}/PKG-INFO +12 -4
- {liyaengine-0.5.0 → liyaengine-0.6.0}/README.md +11 -3
- {liyaengine-0.5.0 → liyaengine-0.6.0}/pyproject.toml +1 -1
- {liyaengine-0.5.0 → liyaengine-0.6.0}/src/liyaengine/__init__.py +3 -2
- {liyaengine-0.5.0 → liyaengine-0.6.0}/src/liyaengine/resources/domains.py +124 -27
- {liyaengine-0.5.0 → liyaengine-0.6.0}/tests/test_domains.py +67 -4
- {liyaengine-0.5.0 → liyaengine-0.6.0}/.github/workflows/ci.yml +0 -0
- {liyaengine-0.5.0 → liyaengine-0.6.0}/.gitignore +0 -0
- {liyaengine-0.5.0 → liyaengine-0.6.0}/LICENSE +0 -0
- {liyaengine-0.5.0 → liyaengine-0.6.0}/src/liyaengine/_http.py +0 -0
- {liyaengine-0.5.0 → liyaengine-0.6.0}/src/liyaengine/client.py +0 -0
- {liyaengine-0.5.0 → liyaengine-0.6.0}/src/liyaengine/errors.py +0 -0
- {liyaengine-0.5.0 → liyaengine-0.6.0}/src/liyaengine/py.typed +0 -0
- {liyaengine-0.5.0 → liyaengine-0.6.0}/src/liyaengine/resources/__init__.py +0 -0
- {liyaengine-0.5.0 → liyaengine-0.6.0}/src/liyaengine/resources/agents.py +0 -0
- {liyaengine-0.5.0 → liyaengine-0.6.0}/src/liyaengine/resources/collections.py +0 -0
- {liyaengine-0.5.0 → liyaengine-0.6.0}/src/liyaengine/resources/evaluations.py +0 -0
- {liyaengine-0.5.0 → liyaengine-0.6.0}/src/liyaengine/resources/workflows.py +0 -0
- {liyaengine-0.5.0 → liyaengine-0.6.0}/tests/test_agents.py +0 -0
- {liyaengine-0.5.0 → liyaengine-0.6.0}/tests/test_collections.py +0 -0
- {liyaengine-0.5.0 → liyaengine-0.6.0}/tests/test_evaluations.py +0 -0
- {liyaengine-0.5.0 → liyaengine-0.6.0}/tests/test_workflows.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: liyaengine
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: Official Python client for the Liya Engine public API
|
|
5
5
|
Project-URL: Homepage, https://liyaengine.ai
|
|
6
6
|
Project-URL: Documentation, https://liyaengine.ai/docs/sdks/python
|
|
@@ -73,14 +73,23 @@ domain = client.domains.create(domain_key="billing", display_name="Billing")
|
|
|
73
73
|
|
|
74
74
|
intent = client.domains.intents.create(
|
|
75
75
|
"billing", intent_key="refund-status", display_name="Refund Status",
|
|
76
|
+
description="Answer refund-status questions.",
|
|
76
77
|
prompt_template="You are a billing assistant. Question: {{message}}",
|
|
78
|
+
# Agent mode, per-intent execution/retrieval/cache overrides — optional:
|
|
79
|
+
agent_config={"enabled": True, "max_steps": 3},
|
|
77
80
|
)
|
|
78
81
|
|
|
82
|
+
one_intent = client.domains.intents.get("billing", "refund-status")
|
|
83
|
+
|
|
84
|
+
# Every update creates a restorable version snapshot automatically.
|
|
85
|
+
versions = client.domains.intents.versions.list("billing", "refund-status")
|
|
86
|
+
client.domains.intents.versions.restore("billing", "refund-status", versions[0].version_number)
|
|
87
|
+
|
|
79
88
|
# Direct retrieval — no LLM call, useful for testing knowledge scoping.
|
|
80
89
|
result = client.domains.query("billing", query="refund timeline")
|
|
81
90
|
```
|
|
82
91
|
|
|
83
|
-
>
|
|
92
|
+
> `domains.update()`/`domains.intents.update()` return `{"updated": 1}`, not the updated object — call `get()`/`list()` again for the fresh state. Guardrail policy attachment is still dashboard-only (a separate resource with no `/v1` route yet). To bind an intent's prompt to a Prompt Studio library version instead of inline text, pass `prompt_binding={"kind": "library_version", "prompt_id": ..., "version_id": ..., "content_hash": ...}` in place of `prompt_template` — editing `prompt_template` directly afterward without also passing `prompt_binding` silently detaches the binding.
|
|
84
93
|
|
|
85
94
|
## Collections
|
|
86
95
|
|
|
@@ -202,13 +211,12 @@ LiyaEngine(
|
|
|
202
211
|
|
|
203
212
|
## Roadmap
|
|
204
213
|
|
|
205
|
-
- [x] Domains & Intents (
|
|
214
|
+
- [x] Domains & Intents (full CRUD parity with the dashboard, prompt binding, agent/execution/retrieval/cache config, versioning, direct retrieval query, narrow document upload — guardrail policy attachment still dashboard-only)
|
|
206
215
|
- [x] Collections
|
|
207
216
|
- [x] Agents (full CRUD, deploy, run, run/session history)
|
|
208
217
|
- [x] Workflows (full CRUD, toggle, deploy, webhook secret rotate, run, run history)
|
|
209
218
|
- [x] Evaluations (Datasets/Cases/Suites/Runs/Reviews CRUD, suite execution, cancel/resume, statistical + pairwise compare, standalone scoring)
|
|
210
219
|
- [ ] Full KBaaS (document list/get/delete, async ingestion jobs + URL crawl, collection↔document/domain attach-detach, analytics)
|
|
211
|
-
- [ ] Domain/Intent config parity (agent/execution/retrieval/cache config, guardrail policy attachment, versioning)
|
|
212
220
|
- [ ] Run / Run (streaming)
|
|
213
221
|
- [ ] Guardrail Policies
|
|
214
222
|
- [ ] Prompt Studio (holding until the feature itself is committed/merged upstream)
|
|
@@ -44,14 +44,23 @@ domain = client.domains.create(domain_key="billing", display_name="Billing")
|
|
|
44
44
|
|
|
45
45
|
intent = client.domains.intents.create(
|
|
46
46
|
"billing", intent_key="refund-status", display_name="Refund Status",
|
|
47
|
+
description="Answer refund-status questions.",
|
|
47
48
|
prompt_template="You are a billing assistant. Question: {{message}}",
|
|
49
|
+
# Agent mode, per-intent execution/retrieval/cache overrides — optional:
|
|
50
|
+
agent_config={"enabled": True, "max_steps": 3},
|
|
48
51
|
)
|
|
49
52
|
|
|
53
|
+
one_intent = client.domains.intents.get("billing", "refund-status")
|
|
54
|
+
|
|
55
|
+
# Every update creates a restorable version snapshot automatically.
|
|
56
|
+
versions = client.domains.intents.versions.list("billing", "refund-status")
|
|
57
|
+
client.domains.intents.versions.restore("billing", "refund-status", versions[0].version_number)
|
|
58
|
+
|
|
50
59
|
# Direct retrieval — no LLM call, useful for testing knowledge scoping.
|
|
51
60
|
result = client.domains.query("billing", query="refund timeline")
|
|
52
61
|
```
|
|
53
62
|
|
|
54
|
-
>
|
|
63
|
+
> `domains.update()`/`domains.intents.update()` return `{"updated": 1}`, not the updated object — call `get()`/`list()` again for the fresh state. Guardrail policy attachment is still dashboard-only (a separate resource with no `/v1` route yet). To bind an intent's prompt to a Prompt Studio library version instead of inline text, pass `prompt_binding={"kind": "library_version", "prompt_id": ..., "version_id": ..., "content_hash": ...}` in place of `prompt_template` — editing `prompt_template` directly afterward without also passing `prompt_binding` silently detaches the binding.
|
|
55
64
|
|
|
56
65
|
## Collections
|
|
57
66
|
|
|
@@ -173,13 +182,12 @@ LiyaEngine(
|
|
|
173
182
|
|
|
174
183
|
## Roadmap
|
|
175
184
|
|
|
176
|
-
- [x] Domains & Intents (
|
|
185
|
+
- [x] Domains & Intents (full CRUD parity with the dashboard, prompt binding, agent/execution/retrieval/cache config, versioning, direct retrieval query, narrow document upload — guardrail policy attachment still dashboard-only)
|
|
177
186
|
- [x] Collections
|
|
178
187
|
- [x] Agents (full CRUD, deploy, run, run/session history)
|
|
179
188
|
- [x] Workflows (full CRUD, toggle, deploy, webhook secret rotate, run, run history)
|
|
180
189
|
- [x] Evaluations (Datasets/Cases/Suites/Runs/Reviews CRUD, suite execution, cancel/resume, statistical + pairwise compare, standalone scoring)
|
|
181
190
|
- [ ] Full KBaaS (document list/get/delete, async ingestion jobs + URL crawl, collection↔document/domain attach-detach, analytics)
|
|
182
|
-
- [ ] Domain/Intent config parity (agent/execution/retrieval/cache config, guardrail policy attachment, versioning)
|
|
183
191
|
- [ ] Run / Run (streaming)
|
|
184
192
|
- [ ] Guardrail Policies
|
|
185
193
|
- [ ] Prompt Studio (holding until the feature itself is committed/merged upstream)
|
|
@@ -4,7 +4,7 @@ from .resources.agents import Agent
|
|
|
4
4
|
from .resources.collections import Collection
|
|
5
5
|
from .resources.workflows import Workflow
|
|
6
6
|
from .resources.evaluations import EvalDataset, EvalCase, EvalSuite, EvalRun, EvalReview
|
|
7
|
-
from .resources.domains import Domain, Intent, DomainSource
|
|
7
|
+
from .resources.domains import Domain, Intent, DomainSource, IntentVersionSummary
|
|
8
8
|
|
|
9
9
|
__all__ = [
|
|
10
10
|
"LiyaEngine",
|
|
@@ -21,6 +21,7 @@ __all__ = [
|
|
|
21
21
|
"Domain",
|
|
22
22
|
"Intent",
|
|
23
23
|
"DomainSource",
|
|
24
|
+
"IntentVersionSummary",
|
|
24
25
|
]
|
|
25
26
|
|
|
26
|
-
__version__ = "0.
|
|
27
|
+
__version__ = "0.6.0"
|
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from dataclasses import dataclass
|
|
4
|
-
from typing import Any, Dict, List, Optional, cast
|
|
4
|
+
from typing import Any, Dict, List, Literal, Optional, TypedDict, Union, cast
|
|
5
5
|
from urllib.parse import quote
|
|
6
6
|
|
|
7
7
|
from .._http import HttpClient
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
class InlinePromptBinding(TypedDict):
|
|
11
|
+
kind: Literal["inline"]
|
|
12
|
+
content: str
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class LibraryVersionPromptBinding(TypedDict):
|
|
16
|
+
"""Pinned to one exact, immutable, content-hashed Prompt Studio version —
|
|
17
|
+
deliberately rejects mutable aliases like "latest" or "production"."""
|
|
18
|
+
|
|
19
|
+
kind: Literal["library_version"]
|
|
20
|
+
prompt_id: str
|
|
21
|
+
version_id: str
|
|
22
|
+
content_hash: str
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
PromptBinding = Union[InlinePromptBinding, LibraryVersionPromptBinding]
|
|
26
|
+
|
|
27
|
+
|
|
10
28
|
@dataclass(frozen=True)
|
|
11
29
|
class Intent:
|
|
12
|
-
"""Real
|
|
13
|
-
|
|
14
|
-
not on create()/update()'s keyword args below."""
|
|
30
|
+
"""Real column also includes guardrail_policy_id — dashboard-only to write
|
|
31
|
+
today, not on create()/update()'s keyword args below."""
|
|
15
32
|
|
|
16
33
|
id: str
|
|
17
34
|
tenant_id: str
|
|
@@ -20,9 +37,14 @@ class Intent:
|
|
|
20
37
|
display_name: str
|
|
21
38
|
description: Optional[str]
|
|
22
39
|
prompt_template: str
|
|
40
|
+
prompt_binding: Optional[PromptBinding]
|
|
23
41
|
output_schema: Optional[Dict[str, Any]]
|
|
24
42
|
input_schema: Optional[Dict[str, Any]]
|
|
25
43
|
guardrails_config: Optional[Dict[str, Any]]
|
|
44
|
+
agent_config: Optional[Dict[str, Any]]
|
|
45
|
+
execution_config: Optional[Dict[str, Any]]
|
|
46
|
+
retrieval_config: Optional[Dict[str, Any]]
|
|
47
|
+
cache_config: Optional[Dict[str, Any]]
|
|
26
48
|
is_active: bool
|
|
27
49
|
sort_order: int
|
|
28
50
|
created_at: str
|
|
@@ -33,17 +55,40 @@ class Intent:
|
|
|
33
55
|
return cls(
|
|
34
56
|
id=data["id"], tenant_id=data["tenant_id"], domain_key=data["domain_key"], intent_key=data["intent_key"],
|
|
35
57
|
display_name=data["display_name"], description=data.get("description"),
|
|
36
|
-
prompt_template=data["prompt_template"],
|
|
37
|
-
|
|
58
|
+
prompt_template=data["prompt_template"], prompt_binding=data.get("prompt_binding"),
|
|
59
|
+
output_schema=data.get("output_schema"), input_schema=data.get("input_schema"),
|
|
60
|
+
guardrails_config=data.get("guardrails_config"), agent_config=data.get("agent_config"),
|
|
61
|
+
execution_config=data.get("execution_config"), retrieval_config=data.get("retrieval_config"),
|
|
62
|
+
cache_config=data.get("cache_config"),
|
|
38
63
|
is_active=data["is_active"], sort_order=data["sort_order"],
|
|
39
64
|
created_at=data["created_at"], updated_at=data["updated_at"],
|
|
40
65
|
)
|
|
41
66
|
|
|
42
67
|
|
|
68
|
+
@dataclass(frozen=True)
|
|
69
|
+
class IntentVersionSummary:
|
|
70
|
+
id: str
|
|
71
|
+
version_number: int
|
|
72
|
+
changed_fields: List[str]
|
|
73
|
+
change_type: Literal["create", "update", "restore"]
|
|
74
|
+
restored_from_version: Optional[int]
|
|
75
|
+
created_by: Optional[str]
|
|
76
|
+
actor_name: Optional[str]
|
|
77
|
+
created_at: str
|
|
78
|
+
|
|
79
|
+
@classmethod
|
|
80
|
+
def _from_dict(cls, data: Dict[str, Any]) -> "IntentVersionSummary":
|
|
81
|
+
return cls(
|
|
82
|
+
id=data["id"], version_number=data["version_number"], changed_fields=data["changed_fields"],
|
|
83
|
+
change_type=data["change_type"], restored_from_version=data.get("restored_from_version"),
|
|
84
|
+
created_by=data.get("created_by"), actor_name=data.get("actorName"), created_at=data["created_at"],
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
|
|
43
88
|
@dataclass(frozen=True)
|
|
44
89
|
class Domain:
|
|
45
|
-
"""Real columns also include
|
|
46
|
-
|
|
90
|
+
"""Real columns also include guardrail_policy_id/tools_config/default_top_k/
|
|
91
|
+
default_similarity_threshold — dashboard-only to write today."""
|
|
47
92
|
|
|
48
93
|
id: str
|
|
49
94
|
tenant_id: str
|
|
@@ -53,8 +98,10 @@ class Domain:
|
|
|
53
98
|
icon: str
|
|
54
99
|
color: str
|
|
55
100
|
system_prompt: Optional[str]
|
|
101
|
+
prompt_binding: Optional[PromptBinding]
|
|
56
102
|
context_enrichment_webhook_url: Optional[str]
|
|
57
103
|
retrieval_scope: Optional[str]
|
|
104
|
+
status: Literal["draft", "active", "archived"]
|
|
58
105
|
is_active: bool
|
|
59
106
|
created_at: str
|
|
60
107
|
updated_at: str
|
|
@@ -69,8 +116,10 @@ class Domain:
|
|
|
69
116
|
id=data["id"], tenant_id=data["tenant_id"], domain_key=data["domain_key"],
|
|
70
117
|
display_name=data["display_name"], description=data.get("description"),
|
|
71
118
|
icon=data["icon"], color=data["color"], system_prompt=data.get("system_prompt"),
|
|
119
|
+
prompt_binding=data.get("prompt_binding"),
|
|
72
120
|
context_enrichment_webhook_url=data.get("context_enrichment_webhook_url"),
|
|
73
|
-
retrieval_scope=data.get("retrieval_scope"),
|
|
121
|
+
retrieval_scope=data.get("retrieval_scope"), status=data.get("status", "active"),
|
|
122
|
+
is_active=data["is_active"],
|
|
74
123
|
created_at=data["created_at"], updated_at=data["updated_at"],
|
|
75
124
|
intents=[Intent._from_dict(i) for i in intents] if intents is not None else None,
|
|
76
125
|
source_types=data.get("source_types"),
|
|
@@ -125,14 +174,39 @@ class IntentCatalogEntry:
|
|
|
125
174
|
)
|
|
126
175
|
|
|
127
176
|
|
|
177
|
+
class DomainIntentVersionsResource:
|
|
178
|
+
def __init__(self, http: HttpClient) -> None:
|
|
179
|
+
self._http = http
|
|
180
|
+
|
|
181
|
+
def list(self, domain_key: str, intent_key: str) -> List[IntentVersionSummary]:
|
|
182
|
+
"""Newest first, max 50."""
|
|
183
|
+
data = self._http.get(f"/v1/domains/{quote(domain_key)}/intents/{quote(intent_key)}/versions")
|
|
184
|
+
return [IntentVersionSummary._from_dict(v) for v in data["versions"]]
|
|
185
|
+
|
|
186
|
+
def get(self, domain_key: str, intent_key: str, version_number: int) -> IntentVersionSummary:
|
|
187
|
+
data = self._http.get(f"/v1/domains/{quote(domain_key)}/intents/{quote(intent_key)}/versions/{version_number}")
|
|
188
|
+
return IntentVersionSummary._from_dict(data["version"])
|
|
189
|
+
|
|
190
|
+
def restore(self, domain_key: str, intent_key: str, version_number: int) -> Intent:
|
|
191
|
+
"""Writes the version's snapshot back onto the live intent. The restore itself is versioned too."""
|
|
192
|
+
data = self._http.post(f"/v1/domains/{quote(domain_key)}/intents/{quote(intent_key)}/versions/{version_number}/restore", {})
|
|
193
|
+
return Intent._from_dict(data["intent"])
|
|
194
|
+
|
|
195
|
+
|
|
128
196
|
class DomainIntentsResource:
|
|
129
197
|
def __init__(self, http: HttpClient) -> None:
|
|
130
198
|
self._http = http
|
|
199
|
+
self.versions = DomainIntentVersionsResource(http)
|
|
131
200
|
|
|
132
201
|
def list(self, domain_key: str) -> List[Intent]:
|
|
133
202
|
data = self._http.get(f"/v1/domains/{quote(domain_key)}/intents")
|
|
134
203
|
return [Intent._from_dict(i) for i in data["intents"]]
|
|
135
204
|
|
|
205
|
+
def get(self, domain_key: str, intent_key: str) -> Intent:
|
|
206
|
+
"""No get-single-intent route existed before this — now it does."""
|
|
207
|
+
data = self._http.get(f"/v1/domains/{quote(domain_key)}/intents/{quote(intent_key)}")
|
|
208
|
+
return Intent._from_dict(data["intent"])
|
|
209
|
+
|
|
136
210
|
# /v1/domains/:key/intents predates the snake_case wire convention every
|
|
137
211
|
# other /v1 resource in this SDK uses, and has real external consumers
|
|
138
212
|
# (A3LearningLabs, Qistara, StoryHire per the API's own doc comment) — its
|
|
@@ -140,14 +214,21 @@ class DomainIntentsResource:
|
|
|
140
214
|
# shape stays consistent with every other resource; changing the wire
|
|
141
215
|
# format itself would break those existing integrations.
|
|
142
216
|
def create(
|
|
143
|
-
self, domain_key: str, *, intent_key: str, display_name: str,
|
|
144
|
-
|
|
145
|
-
|
|
217
|
+
self, domain_key: str, *, intent_key: str, display_name: str, description: str,
|
|
218
|
+
prompt_template: Optional[str] = None, prompt_binding: Optional[PromptBinding] = None,
|
|
219
|
+
output_schema: Optional[Dict[str, Any]] = None, input_schema: Optional[Dict[str, Any]] = None,
|
|
220
|
+
guardrails_config: Optional[Dict[str, Any]] = None, agent_config: Optional[Dict[str, Any]] = None,
|
|
221
|
+
execution_config: Optional[Dict[str, Any]] = None, retrieval_config: Optional[Dict[str, Any]] = None,
|
|
222
|
+
cache_config: Optional[Dict[str, Any]] = None,
|
|
146
223
|
) -> Intent:
|
|
147
|
-
|
|
224
|
+
"""Either prompt_template or prompt_binding is required — pass prompt_binding
|
|
225
|
+
to pin the intent to a Prompt Studio library version instead of inline text."""
|
|
226
|
+
body: Dict[str, Any] = {"intentKey": intent_key, "displayName": display_name, "description": description}
|
|
148
227
|
optional = {
|
|
149
|
-
"
|
|
150
|
-
"inputSchema": input_schema, "guardrailsConfig": guardrails_config,
|
|
228
|
+
"promptTemplate": prompt_template, "promptBinding": prompt_binding,
|
|
229
|
+
"outputSchema": output_schema, "inputSchema": input_schema, "guardrailsConfig": guardrails_config,
|
|
230
|
+
"agentConfig": agent_config, "executionConfig": execution_config,
|
|
231
|
+
"retrievalConfig": retrieval_config, "cacheConfig": cache_config,
|
|
151
232
|
}
|
|
152
233
|
body.update({k: v for k, v in optional.items() if v is not None})
|
|
153
234
|
data = self._http.post(f"/v1/domains/{quote(domain_key)}/intents", body)
|
|
@@ -156,16 +237,24 @@ class DomainIntentsResource:
|
|
|
156
237
|
def update(
|
|
157
238
|
self, domain_key: str, intent_key: str, *, display_name: Optional[str] = None,
|
|
158
239
|
description: Optional[str] = None, prompt_template: Optional[str] = None,
|
|
240
|
+
prompt_binding: Optional[PromptBinding] = None,
|
|
159
241
|
output_schema: Optional[Dict[str, Any]] = None, input_schema: Optional[Dict[str, Any]] = None,
|
|
160
|
-
guardrails_config: Optional[Dict[str, Any]] = None,
|
|
242
|
+
guardrails_config: Optional[Dict[str, Any]] = None, agent_config: Optional[Dict[str, Any]] = None,
|
|
243
|
+
execution_config: Optional[Dict[str, Any]] = None, retrieval_config: Optional[Dict[str, Any]] = None,
|
|
244
|
+
cache_config: Optional[Dict[str, Any]] = None, sort_order: Optional[int] = None,
|
|
245
|
+
model_override: Optional[str] = None, is_active: Optional[bool] = None,
|
|
161
246
|
) -> Dict[str, int]:
|
|
162
|
-
"""Returns {"updated": 1}, not the updated Intent —
|
|
163
|
-
|
|
164
|
-
|
|
247
|
+
"""Returns {"updated": 1}, not the updated Intent — call get() again if
|
|
248
|
+
you need the fresh object. Editing prompt_template without also passing
|
|
249
|
+
prompt_binding detaches any existing binding on this intent."""
|
|
165
250
|
body: Dict[str, Any] = {}
|
|
166
251
|
optional = {
|
|
167
252
|
"displayName": display_name, "description": description, "promptTemplate": prompt_template,
|
|
168
|
-
"
|
|
253
|
+
"promptBinding": prompt_binding, "outputSchema": output_schema, "inputSchema": input_schema,
|
|
254
|
+
"guardrailsConfig": guardrails_config, "agentConfig": agent_config,
|
|
255
|
+
"executionConfig": execution_config, "retrievalConfig": retrieval_config,
|
|
256
|
+
"cacheConfig": cache_config, "sortOrder": sort_order, "modelOverride": model_override,
|
|
257
|
+
"isActive": is_active,
|
|
169
258
|
}
|
|
170
259
|
body.update({k: v for k, v in optional.items() if v is not None})
|
|
171
260
|
return cast(Dict[str, int], self._http.patch(f"/v1/domains/{quote(domain_key)}/intents/{quote(intent_key)}", body))
|
|
@@ -197,9 +286,10 @@ class DomainSourcesResource:
|
|
|
197
286
|
class DomainsResource:
|
|
198
287
|
"""Custom domains — the top-level container tenants configure first (system
|
|
199
288
|
prompt, retrieval scope, then intents and knowledge underneath). Mirrors the
|
|
200
|
-
full /v1/domains surface
|
|
201
|
-
cache config
|
|
202
|
-
dashboard-only (no /v1 route yet
|
|
289
|
+
full /v1/domains surface, including intent versioning (intents.versions) and
|
|
290
|
+
the agent/execution/retrieval/cache config blobs. Guardrail policy attachment
|
|
291
|
+
is still dashboard-only (no /v1 route for that yet — a separate resource
|
|
292
|
+
entirely)."""
|
|
203
293
|
|
|
204
294
|
def __init__(self, http: HttpClient) -> None:
|
|
205
295
|
self._http = http
|
|
@@ -223,12 +313,15 @@ class DomainsResource:
|
|
|
223
313
|
def create(
|
|
224
314
|
self, *, domain_key: str, display_name: str, description: Optional[str] = None,
|
|
225
315
|
icon: Optional[str] = None, color: Optional[str] = None, system_prompt: Optional[str] = None,
|
|
316
|
+
prompt_binding: Optional[PromptBinding] = None,
|
|
226
317
|
context_enrichment_webhook_url: Optional[str] = None,
|
|
318
|
+
status: Optional[Literal["draft", "active", "archived"]] = None,
|
|
227
319
|
) -> Domain:
|
|
228
320
|
body: Dict[str, Any] = {"domainKey": domain_key, "displayName": display_name}
|
|
229
321
|
optional = {
|
|
230
322
|
"description": description, "icon": icon, "color": color, "systemPrompt": system_prompt,
|
|
231
|
-
"
|
|
323
|
+
"promptBinding": prompt_binding,
|
|
324
|
+
"contextEnrichmentWebhookUrl": context_enrichment_webhook_url, "status": status,
|
|
232
325
|
}
|
|
233
326
|
body.update({k: v for k, v in optional.items() if v is not None})
|
|
234
327
|
data = self._http.post("/v1/domains", body)
|
|
@@ -237,14 +330,18 @@ class DomainsResource:
|
|
|
237
330
|
def update(
|
|
238
331
|
self, domain_key: str, *, display_name: Optional[str] = None, description: Optional[str] = None,
|
|
239
332
|
icon: Optional[str] = None, color: Optional[str] = None, system_prompt: Optional[str] = None,
|
|
333
|
+
prompt_binding: Optional[PromptBinding] = None,
|
|
240
334
|
retrieval_scope: Optional[str] = None, context_enrichment_webhook_url: Optional[str] = None,
|
|
335
|
+
status: Optional[Literal["draft", "active", "archived"]] = None,
|
|
241
336
|
) -> Dict[str, int]:
|
|
242
|
-
"""Returns {"updated": 1}, not the updated Domain — call get() again for
|
|
337
|
+
"""Returns {"updated": 1}, not the updated Domain — call get() again for
|
|
338
|
+
the fresh object. Editing system_prompt without also passing
|
|
339
|
+
prompt_binding detaches any existing binding on this domain."""
|
|
243
340
|
body: Dict[str, Any] = {}
|
|
244
341
|
optional = {
|
|
245
342
|
"displayName": display_name, "description": description, "icon": icon, "color": color,
|
|
246
|
-
"systemPrompt": system_prompt, "retrievalScope": retrieval_scope,
|
|
247
|
-
"contextEnrichmentWebhookUrl": context_enrichment_webhook_url,
|
|
343
|
+
"systemPrompt": system_prompt, "promptBinding": prompt_binding, "retrievalScope": retrieval_scope,
|
|
344
|
+
"contextEnrichmentWebhookUrl": context_enrichment_webhook_url, "status": status,
|
|
248
345
|
}
|
|
249
346
|
body.update({k: v for k, v in optional.items() if v is not None})
|
|
250
347
|
return cast(Dict[str, int], self._http.patch(f"/v1/domains/{quote(domain_key)}", body))
|
|
@@ -15,8 +15,10 @@ FIXTURE_DOMAIN = {
|
|
|
15
15
|
"icon": "◆",
|
|
16
16
|
"color": "#6366f1",
|
|
17
17
|
"system_prompt": None,
|
|
18
|
+
"prompt_binding": None,
|
|
18
19
|
"context_enrichment_webhook_url": None,
|
|
19
20
|
"retrieval_scope": None,
|
|
21
|
+
"status": "active",
|
|
20
22
|
"is_active": True,
|
|
21
23
|
"created_at": "2026-01-01T00:00:00.000Z",
|
|
22
24
|
"updated_at": "2026-01-01T00:00:00.000Z",
|
|
@@ -30,15 +32,31 @@ FIXTURE_INTENT = {
|
|
|
30
32
|
"display_name": "Refund Status",
|
|
31
33
|
"description": "Answer refund status questions.",
|
|
32
34
|
"prompt_template": "You are a billing assistant...",
|
|
35
|
+
"prompt_binding": None,
|
|
33
36
|
"output_schema": None,
|
|
34
37
|
"input_schema": None,
|
|
35
38
|
"guardrails_config": None,
|
|
39
|
+
"agent_config": None,
|
|
40
|
+
"execution_config": None,
|
|
41
|
+
"retrieval_config": None,
|
|
42
|
+
"cache_config": None,
|
|
36
43
|
"is_active": True,
|
|
37
44
|
"sort_order": 0,
|
|
38
45
|
"created_at": "2026-01-01T00:00:00.000Z",
|
|
39
46
|
"updated_at": "2026-01-01T00:00:00.000Z",
|
|
40
47
|
}
|
|
41
48
|
|
|
49
|
+
FIXTURE_VERSION = {
|
|
50
|
+
"id": "ver_1",
|
|
51
|
+
"version_number": 1,
|
|
52
|
+
"changed_fields": ["prompt_template"],
|
|
53
|
+
"change_type": "create",
|
|
54
|
+
"restored_from_version": None,
|
|
55
|
+
"created_by": None,
|
|
56
|
+
"actorName": None,
|
|
57
|
+
"created_at": "2026-01-01T00:00:00.000Z",
|
|
58
|
+
}
|
|
59
|
+
|
|
42
60
|
|
|
43
61
|
@pytest.fixture
|
|
44
62
|
def client():
|
|
@@ -57,7 +75,7 @@ def test_domain_crud(client):
|
|
|
57
75
|
respx.post(f"{BASE_URL}/v1/domains").mock(
|
|
58
76
|
return_value=httpx.Response(201, json={"success": True, "data": {"domain": FIXTURE_DOMAIN}})
|
|
59
77
|
)
|
|
60
|
-
created = client.domains.create(domain_key="billing", display_name="Billing")
|
|
78
|
+
created = client.domains.create(domain_key="billing", display_name="Billing", status="draft")
|
|
61
79
|
assert created.domain_key == "billing"
|
|
62
80
|
|
|
63
81
|
respx.get(f"{BASE_URL}/v1/domains/billing").mock(
|
|
@@ -70,7 +88,7 @@ def test_domain_crud(client):
|
|
|
70
88
|
respx.patch(f"{BASE_URL}/v1/domains/billing").mock(
|
|
71
89
|
return_value=httpx.Response(200, json={"success": True, "data": {"updated": 1}})
|
|
72
90
|
)
|
|
73
|
-
updated = client.domains.update("billing", display_name="Billing Support")
|
|
91
|
+
updated = client.domains.update("billing", display_name="Billing Support", status="active")
|
|
74
92
|
assert updated["updated"] == 1
|
|
75
93
|
|
|
76
94
|
respx.delete(f"{BASE_URL}/v1/domains/billing").mock(
|
|
@@ -106,18 +124,28 @@ def test_domain_intents_crud(client):
|
|
|
106
124
|
intents = client.domains.intents.list("billing")
|
|
107
125
|
assert len(intents) == 1
|
|
108
126
|
|
|
127
|
+
respx.get(f"{BASE_URL}/v1/domains/billing/intents/refund-status").mock(
|
|
128
|
+
return_value=httpx.Response(200, json={"success": True, "data": {"intent": FIXTURE_INTENT}})
|
|
129
|
+
)
|
|
130
|
+
fetched = client.domains.intents.get("billing", "refund-status")
|
|
131
|
+
assert fetched.intent_key == "refund-status"
|
|
132
|
+
|
|
109
133
|
respx.post(f"{BASE_URL}/v1/domains/billing/intents").mock(
|
|
110
134
|
return_value=httpx.Response(201, json={"success": True, "data": {"intent": FIXTURE_INTENT}})
|
|
111
135
|
)
|
|
112
136
|
created = client.domains.intents.create(
|
|
113
|
-
"billing", intent_key="refund-status", display_name="Refund Status",
|
|
137
|
+
"billing", intent_key="refund-status", display_name="Refund Status",
|
|
138
|
+
description="Answer refund status questions.", prompt_template="You are a billing assistant...",
|
|
114
139
|
)
|
|
115
140
|
assert created.intent_key == "refund-status"
|
|
116
141
|
|
|
117
142
|
respx.patch(f"{BASE_URL}/v1/domains/billing/intents/refund-status").mock(
|
|
118
143
|
return_value=httpx.Response(200, json={"success": True, "data": {"updated": 1}})
|
|
119
144
|
)
|
|
120
|
-
updated = client.domains.intents.update(
|
|
145
|
+
updated = client.domains.intents.update(
|
|
146
|
+
"billing", "refund-status", display_name="Refund Status v2",
|
|
147
|
+
agent_config={"enabled": True, "max_steps": 3}, sort_order=2,
|
|
148
|
+
)
|
|
121
149
|
assert updated["updated"] == 1
|
|
122
150
|
|
|
123
151
|
respx.delete(f"{BASE_URL}/v1/domains/billing/intents/refund-status").mock(
|
|
@@ -126,6 +154,41 @@ def test_domain_intents_crud(client):
|
|
|
126
154
|
client.domains.intents.delete("billing", "refund-status")
|
|
127
155
|
|
|
128
156
|
|
|
157
|
+
@respx.mock
|
|
158
|
+
def test_domain_intent_create_with_prompt_binding(client):
|
|
159
|
+
respx.post(f"{BASE_URL}/v1/domains/billing/intents").mock(
|
|
160
|
+
return_value=httpx.Response(201, json={"success": True, "data": {"intent": FIXTURE_INTENT}})
|
|
161
|
+
)
|
|
162
|
+
created = client.domains.intents.create(
|
|
163
|
+
"billing", intent_key="refund-status", display_name="Refund Status",
|
|
164
|
+
description="Answer refund status questions.",
|
|
165
|
+
prompt_binding={"kind": "library_version", "prompt_id": "prompt_1", "version_id": "version_2", "content_hash": "sha256:" + "a" * 64},
|
|
166
|
+
)
|
|
167
|
+
assert created.intent_key == "refund-status"
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
@respx.mock
|
|
171
|
+
def test_domain_intent_versions(client):
|
|
172
|
+
respx.get(f"{BASE_URL}/v1/domains/billing/intents/refund-status/versions").mock(
|
|
173
|
+
return_value=httpx.Response(200, json={"success": True, "data": {"versions": [FIXTURE_VERSION]}})
|
|
174
|
+
)
|
|
175
|
+
versions = client.domains.intents.versions.list("billing", "refund-status")
|
|
176
|
+
assert len(versions) == 1
|
|
177
|
+
assert versions[0].change_type == "create"
|
|
178
|
+
|
|
179
|
+
respx.get(f"{BASE_URL}/v1/domains/billing/intents/refund-status/versions/1").mock(
|
|
180
|
+
return_value=httpx.Response(200, json={"success": True, "data": {"version": FIXTURE_VERSION}})
|
|
181
|
+
)
|
|
182
|
+
version = client.domains.intents.versions.get("billing", "refund-status", 1)
|
|
183
|
+
assert version.version_number == 1
|
|
184
|
+
|
|
185
|
+
respx.post(f"{BASE_URL}/v1/domains/billing/intents/refund-status/versions/1/restore").mock(
|
|
186
|
+
return_value=httpx.Response(200, json={"success": True, "data": {"intent": FIXTURE_INTENT}})
|
|
187
|
+
)
|
|
188
|
+
restored = client.domains.intents.versions.restore("billing", "refund-status", 1)
|
|
189
|
+
assert restored.intent_key == "refund-status"
|
|
190
|
+
|
|
191
|
+
|
|
129
192
|
@respx.mock
|
|
130
193
|
def test_domain_sources_crud(client):
|
|
131
194
|
respx.get(f"{BASE_URL}/v1/domains/billing/sources").mock(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|