liyaengine 0.8.0__tar.gz → 0.9.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.8.0 → liyaengine-0.9.0}/PKG-INFO +40 -1
- {liyaengine-0.8.0 → liyaengine-0.9.0}/README.md +39 -0
- {liyaengine-0.8.0 → liyaengine-0.9.0}/pyproject.toml +1 -1
- {liyaengine-0.8.0 → liyaengine-0.9.0}/src/liyaengine/__init__.py +7 -1
- liyaengine-0.9.0/src/liyaengine/resources/domain_tools.py +135 -0
- {liyaengine-0.8.0 → liyaengine-0.9.0}/src/liyaengine/resources/domains.py +2 -0
- {liyaengine-0.8.0 → liyaengine-0.9.0}/tests/test_domains.py +74 -1
- {liyaengine-0.8.0 → liyaengine-0.9.0}/.github/workflows/ci.yml +0 -0
- {liyaengine-0.8.0 → liyaengine-0.9.0}/.gitignore +0 -0
- {liyaengine-0.8.0 → liyaengine-0.9.0}/LICENSE +0 -0
- {liyaengine-0.8.0 → liyaengine-0.9.0}/src/liyaengine/_http.py +0 -0
- {liyaengine-0.8.0 → liyaengine-0.9.0}/src/liyaengine/client.py +0 -0
- {liyaengine-0.8.0 → liyaengine-0.9.0}/src/liyaengine/errors.py +0 -0
- {liyaengine-0.8.0 → liyaengine-0.9.0}/src/liyaengine/py.typed +0 -0
- {liyaengine-0.8.0 → liyaengine-0.9.0}/src/liyaengine/resources/__init__.py +0 -0
- {liyaengine-0.8.0 → liyaengine-0.9.0}/src/liyaengine/resources/agents.py +0 -0
- {liyaengine-0.8.0 → liyaengine-0.9.0}/src/liyaengine/resources/collections.py +0 -0
- {liyaengine-0.8.0 → liyaengine-0.9.0}/src/liyaengine/resources/documents.py +0 -0
- {liyaengine-0.8.0 → liyaengine-0.9.0}/src/liyaengine/resources/evaluations.py +0 -0
- {liyaengine-0.8.0 → liyaengine-0.9.0}/src/liyaengine/resources/run.py +0 -0
- {liyaengine-0.8.0 → liyaengine-0.9.0}/src/liyaengine/resources/workflows.py +0 -0
- {liyaengine-0.8.0 → liyaengine-0.9.0}/tests/test_agents.py +0 -0
- {liyaengine-0.8.0 → liyaengine-0.9.0}/tests/test_collections.py +0 -0
- {liyaengine-0.8.0 → liyaengine-0.9.0}/tests/test_documents.py +0 -0
- {liyaengine-0.8.0 → liyaengine-0.9.0}/tests/test_evaluations.py +0 -0
- {liyaengine-0.8.0 → liyaengine-0.9.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.9.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
|
|
@@ -91,6 +91,44 @@ result = client.domains.query("billing", query="refund timeline")
|
|
|
91
91
|
|
|
92
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.
|
|
93
93
|
|
|
94
|
+
## Domain Tools
|
|
95
|
+
|
|
96
|
+
The custom webhook tools an agent-mode intent (`agent_config={"enabled": True, ...}`) can call mid-conversation — e.g. a real order-status lookup against your own backend. Every custom tool is dispatched by one generic platform tool, `webhook_sender`; the LLM calls `webhook_sender({tool_name, payload})`, and `webhook_sender` looks up `tool_name` in the domain's `custom_tools` to find the real endpoint.
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
# 1. Define the tool on the domain.
|
|
100
|
+
client.domains.tools.update(
|
|
101
|
+
"shipping-support",
|
|
102
|
+
# webhook_sender must be explicitly enabled here — defining custom_tools
|
|
103
|
+
# alone does nothing, since it's webhook_sender that actually dispatches them.
|
|
104
|
+
enabled_platform_tools=["webhook_sender"],
|
|
105
|
+
custom_tools=[{
|
|
106
|
+
"name": "lookup_order",
|
|
107
|
+
"display_name": "Order Lookup",
|
|
108
|
+
"description": 'Looks up a real order by number and returns its current status. Call with {"order_number": "..."}.',
|
|
109
|
+
"endpoint_url": "https://fernbankoutdoor.com/api/liya-tools/lookup-order",
|
|
110
|
+
"auth_type": "api_key",
|
|
111
|
+
"auth_value": os.environ["LIYA_TOOL_SHARED_SECRET"], # write-only — never returned by get()
|
|
112
|
+
}],
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
# 2. Verify the endpoint actually works before wiring it into a live intent.
|
|
116
|
+
test_result = client.domains.tools.test("shipping-support", "lookup_order", {"order_number": "A1092"})
|
|
117
|
+
|
|
118
|
+
# 3. Point the intent at "webhook_sender" — NOT "lookup_order". agent_config["tools"]
|
|
119
|
+
# is a platform-tool allowlist; "lookup_order" is only ever an *argument* the
|
|
120
|
+
# model passes to webhook_sender at call time, never an entry in this array.
|
|
121
|
+
client.domains.intents.update(
|
|
122
|
+
"shipping-support", "track-order",
|
|
123
|
+
agent_config={"enabled": True, "tools": ["webhook_sender"], "max_steps": 3},
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
config = client.domains.tools.get("shipping-support")
|
|
127
|
+
# config.custom_tools[0].auth_configured is True — the real credential is never returned, only whether one is set.
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
> **Two real footguns, easy to hit on the first try:** (1) `enabled_platform_tools` must include `"webhook_sender"` — a domain with only `custom_tools` defined and no platform tool enabled registers *zero* tools, and the model will just apologize that it can't look anything up (or worse, quietly fabricate a plausible-looking answer if your prompt insists it report a result). (2) `agent_config["tools"]` takes platform tool names, so it's `["webhook_sender"]`, never `["lookup_order"]` — the custom tool's own name is an argument, not an allowlist entry. Beyond that: there's no JSON-schema parameter definition for a custom tool today — `description` is the *only* thing the model sees to decide when and how to call it, so be explicit about the fields you expect. `custom_tools` in `update()` REPLACES the entire array, not a per-tool patch. Omit `auth_value` on an update to preserve the existing stored credential; it's encrypted separately and never round-trips back to a reader.
|
|
131
|
+
|
|
94
132
|
## Run
|
|
95
133
|
|
|
96
134
|
The primary way to actually invoke an intent — built-in pack or custom domain — and get a real, LLM-generated response back. `agents.run()` and a domain's public `/v1/{domain}/{intent}` route both reach this same endpoint under the hood; call it directly when you don't need an Agent's multi-turn orchestration on top.
|
|
@@ -302,6 +340,7 @@ LiyaEngine(
|
|
|
302
340
|
- [x] Evaluations (Datasets/Cases/Suites/Runs/Reviews CRUD, suite execution, cancel/resume, statistical + pairwise compare, standalone scoring)
|
|
303
341
|
- [x] Full KBaaS (document list/get/delete/upload/push, async ingestion jobs + URL crawl, collection↔document/domain attach-detach, analytics/connections)
|
|
304
342
|
- [x] Run / Run (streaming) — built-in packs only for streaming; custom domains use non-streaming `run()`
|
|
343
|
+
- [x] Domain agentic tool configuration (previously dashboard-only)
|
|
305
344
|
- [ ] Flagged-chunk review
|
|
306
345
|
- [ ] Guardrail Policies
|
|
307
346
|
- [ ] Prompt Studio (holding until the feature itself is committed/merged upstream)
|
|
@@ -62,6 +62,44 @@ result = client.domains.query("billing", query="refund timeline")
|
|
|
62
62
|
|
|
63
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.
|
|
64
64
|
|
|
65
|
+
## Domain Tools
|
|
66
|
+
|
|
67
|
+
The custom webhook tools an agent-mode intent (`agent_config={"enabled": True, ...}`) can call mid-conversation — e.g. a real order-status lookup against your own backend. Every custom tool is dispatched by one generic platform tool, `webhook_sender`; the LLM calls `webhook_sender({tool_name, payload})`, and `webhook_sender` looks up `tool_name` in the domain's `custom_tools` to find the real endpoint.
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
# 1. Define the tool on the domain.
|
|
71
|
+
client.domains.tools.update(
|
|
72
|
+
"shipping-support",
|
|
73
|
+
# webhook_sender must be explicitly enabled here — defining custom_tools
|
|
74
|
+
# alone does nothing, since it's webhook_sender that actually dispatches them.
|
|
75
|
+
enabled_platform_tools=["webhook_sender"],
|
|
76
|
+
custom_tools=[{
|
|
77
|
+
"name": "lookup_order",
|
|
78
|
+
"display_name": "Order Lookup",
|
|
79
|
+
"description": 'Looks up a real order by number and returns its current status. Call with {"order_number": "..."}.',
|
|
80
|
+
"endpoint_url": "https://fernbankoutdoor.com/api/liya-tools/lookup-order",
|
|
81
|
+
"auth_type": "api_key",
|
|
82
|
+
"auth_value": os.environ["LIYA_TOOL_SHARED_SECRET"], # write-only — never returned by get()
|
|
83
|
+
}],
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
# 2. Verify the endpoint actually works before wiring it into a live intent.
|
|
87
|
+
test_result = client.domains.tools.test("shipping-support", "lookup_order", {"order_number": "A1092"})
|
|
88
|
+
|
|
89
|
+
# 3. Point the intent at "webhook_sender" — NOT "lookup_order". agent_config["tools"]
|
|
90
|
+
# is a platform-tool allowlist; "lookup_order" is only ever an *argument* the
|
|
91
|
+
# model passes to webhook_sender at call time, never an entry in this array.
|
|
92
|
+
client.domains.intents.update(
|
|
93
|
+
"shipping-support", "track-order",
|
|
94
|
+
agent_config={"enabled": True, "tools": ["webhook_sender"], "max_steps": 3},
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
config = client.domains.tools.get("shipping-support")
|
|
98
|
+
# config.custom_tools[0].auth_configured is True — the real credential is never returned, only whether one is set.
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
> **Two real footguns, easy to hit on the first try:** (1) `enabled_platform_tools` must include `"webhook_sender"` — a domain with only `custom_tools` defined and no platform tool enabled registers *zero* tools, and the model will just apologize that it can't look anything up (or worse, quietly fabricate a plausible-looking answer if your prompt insists it report a result). (2) `agent_config["tools"]` takes platform tool names, so it's `["webhook_sender"]`, never `["lookup_order"]` — the custom tool's own name is an argument, not an allowlist entry. Beyond that: there's no JSON-schema parameter definition for a custom tool today — `description` is the *only* thing the model sees to decide when and how to call it, so be explicit about the fields you expect. `custom_tools` in `update()` REPLACES the entire array, not a per-tool patch. Omit `auth_value` on an update to preserve the existing stored credential; it's encrypted separately and never round-trips back to a reader.
|
|
102
|
+
|
|
65
103
|
## Run
|
|
66
104
|
|
|
67
105
|
The primary way to actually invoke an intent — built-in pack or custom domain — and get a real, LLM-generated response back. `agents.run()` and a domain's public `/v1/{domain}/{intent}` route both reach this same endpoint under the hood; call it directly when you don't need an Agent's multi-turn orchestration on top.
|
|
@@ -273,6 +311,7 @@ LiyaEngine(
|
|
|
273
311
|
- [x] Evaluations (Datasets/Cases/Suites/Runs/Reviews CRUD, suite execution, cancel/resume, statistical + pairwise compare, standalone scoring)
|
|
274
312
|
- [x] Full KBaaS (document list/get/delete/upload/push, async ingestion jobs + URL crawl, collection↔document/domain attach-detach, analytics/connections)
|
|
275
313
|
- [x] Run / Run (streaming) — built-in packs only for streaming; custom domains use non-streaming `run()`
|
|
314
|
+
- [x] Domain agentic tool configuration (previously dashboard-only)
|
|
276
315
|
- [ ] Flagged-chunk review
|
|
277
316
|
- [ ] Guardrail Policies
|
|
278
317
|
- [ ] Prompt Studio (holding until the feature itself is committed/merged upstream)
|
|
@@ -7,6 +7,7 @@ from .resources.evaluations import EvalDataset, EvalCase, EvalSuite, EvalRun, Ev
|
|
|
7
7
|
from .resources.domains import Domain, Intent, DomainSource, IntentVersionSummary
|
|
8
8
|
from .resources.documents import Document, DocumentChunk, IngestionJob
|
|
9
9
|
from .resources.run import RunIntentResult, RunStreamEvent, RunTokenEvent, RunDoneEvent, RunErrorEvent
|
|
10
|
+
from .resources.domain_tools import PlatformTool, MaskedCustomTool, DomainToolsConfig, TestDomainToolResult, CustomToolInput
|
|
10
11
|
|
|
11
12
|
__all__ = [
|
|
12
13
|
"LiyaEngine",
|
|
@@ -33,6 +34,11 @@ __all__ = [
|
|
|
33
34
|
"RunTokenEvent",
|
|
34
35
|
"RunDoneEvent",
|
|
35
36
|
"RunErrorEvent",
|
|
37
|
+
"PlatformTool",
|
|
38
|
+
"MaskedCustomTool",
|
|
39
|
+
"DomainToolsConfig",
|
|
40
|
+
"TestDomainToolResult",
|
|
41
|
+
"CustomToolInput",
|
|
36
42
|
]
|
|
37
43
|
|
|
38
|
-
__version__ = "0.
|
|
44
|
+
__version__ = "0.9.0"
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"""A domain's agentic tool configuration — the custom webhook tools (and
|
|
2
|
+
enabled platform tools) an agent-mode intent (agent_config.enabled) can
|
|
3
|
+
call mid-conversation. Was dashboard-only before this; the tool's real
|
|
4
|
+
definition (endpoint, auth) can now be set from here too, not just
|
|
5
|
+
referenced by name in an intent's agent_config.tools[].
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
from typing import Any, Dict, List, Literal, Optional, TypedDict, cast
|
|
11
|
+
from urllib.parse import quote
|
|
12
|
+
|
|
13
|
+
from .._http import HttpClient
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class CustomToolInput(TypedDict, total=False):
|
|
17
|
+
"""URL-safe `name` (/^[a-z0-9_-]+$/) is what agent_config.tools[] references,
|
|
18
|
+
and what the model passes as tool_name at run time. `description` is the
|
|
19
|
+
ONLY thing the model sees to decide when/how to call this tool — there's
|
|
20
|
+
no separate JSON-schema parameter definition today, so be explicit about
|
|
21
|
+
expected fields there. `auth_value` is write-only: omit on update to keep
|
|
22
|
+
the existing stored credential; required on first create for any
|
|
23
|
+
auth_type other than "none"."""
|
|
24
|
+
|
|
25
|
+
name: str
|
|
26
|
+
display_name: str
|
|
27
|
+
description: str
|
|
28
|
+
endpoint_url: str
|
|
29
|
+
auth_type: Literal["none", "api_key", "bearer"]
|
|
30
|
+
auth_value: str
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass(frozen=True)
|
|
34
|
+
class PlatformTool:
|
|
35
|
+
name: str
|
|
36
|
+
description: str
|
|
37
|
+
enabled: bool
|
|
38
|
+
|
|
39
|
+
@classmethod
|
|
40
|
+
def _from_dict(cls, data: Dict[str, Any]) -> "PlatformTool":
|
|
41
|
+
return cls(name=data["name"], description=data["description"], enabled=data["enabled"])
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@dataclass(frozen=True)
|
|
45
|
+
class MaskedCustomTool:
|
|
46
|
+
"""A CustomToolInput as returned by the API — auth_value replaced by
|
|
47
|
+
auth_configured; the real credential is never returned once stored."""
|
|
48
|
+
|
|
49
|
+
name: str
|
|
50
|
+
display_name: str
|
|
51
|
+
description: str
|
|
52
|
+
endpoint_url: str
|
|
53
|
+
auth_type: Literal["none", "api_key", "bearer"]
|
|
54
|
+
auth_configured: bool
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def _from_dict(cls, data: Dict[str, Any]) -> "MaskedCustomTool":
|
|
58
|
+
return cls(
|
|
59
|
+
name=data["name"], display_name=data["display_name"], description=data["description"],
|
|
60
|
+
endpoint_url=data["endpoint_url"], auth_type=data["auth_type"], auth_configured=data["auth_configured"],
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@dataclass(frozen=True)
|
|
65
|
+
class DomainToolsConfig:
|
|
66
|
+
platform_tools: List[PlatformTool]
|
|
67
|
+
custom_tools: List[MaskedCustomTool]
|
|
68
|
+
web_search_configured: bool
|
|
69
|
+
|
|
70
|
+
@classmethod
|
|
71
|
+
def _from_dict(cls, data: Dict[str, Any]) -> "DomainToolsConfig":
|
|
72
|
+
return cls(
|
|
73
|
+
platform_tools=[PlatformTool._from_dict(t) for t in data["platform_tools"]],
|
|
74
|
+
custom_tools=[MaskedCustomTool._from_dict(t) for t in data["custom_tools"]],
|
|
75
|
+
web_search_configured=data["web_search_configured"],
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@dataclass(frozen=True)
|
|
80
|
+
class TestDomainToolResult:
|
|
81
|
+
status_code: int
|
|
82
|
+
ok: bool
|
|
83
|
+
body: Any
|
|
84
|
+
latency_ms: int
|
|
85
|
+
|
|
86
|
+
@classmethod
|
|
87
|
+
def _from_dict(cls, data: Dict[str, Any]) -> "TestDomainToolResult":
|
|
88
|
+
return cls(status_code=data["status_code"], ok=data["ok"], body=data["body"], latency_ms=data["latency_ms"])
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class DomainToolsResource:
|
|
92
|
+
"""Domain-scoped tool configuration. Sits at client.domains.tools rather
|
|
93
|
+
than a top-level resource — a tool only ever exists in the context of
|
|
94
|
+
the one domain it's defined on."""
|
|
95
|
+
|
|
96
|
+
def __init__(self, http: HttpClient) -> None:
|
|
97
|
+
self._http = http
|
|
98
|
+
|
|
99
|
+
def get(self, domain_key: str) -> DomainToolsConfig:
|
|
100
|
+
data = self._http.get(f"/v1/domains/{quote(domain_key)}/tools")
|
|
101
|
+
return DomainToolsConfig._from_dict(data)
|
|
102
|
+
|
|
103
|
+
def update(
|
|
104
|
+
self,
|
|
105
|
+
domain_key: str,
|
|
106
|
+
*,
|
|
107
|
+
enabled_platform_tools: Optional[List[str]] = None,
|
|
108
|
+
custom_tools: Optional[List[CustomToolInput]] = None,
|
|
109
|
+
web_search_api_key: Optional[str] = None,
|
|
110
|
+
) -> DomainToolsConfig:
|
|
111
|
+
"""`custom_tools`, when given, REPLACES the entire array — not a
|
|
112
|
+
per-tool merge/patch. `web_search_api_key=""` clears the stored key;
|
|
113
|
+
omit to leave it unchanged."""
|
|
114
|
+
body: Dict[str, Any] = {}
|
|
115
|
+
if enabled_platform_tools is not None:
|
|
116
|
+
body["enabled_platform_tools"] = enabled_platform_tools
|
|
117
|
+
if custom_tools is not None:
|
|
118
|
+
body["custom_tools"] = custom_tools
|
|
119
|
+
if web_search_api_key is not None:
|
|
120
|
+
body["web_search_api_key"] = web_search_api_key
|
|
121
|
+
data = self._http.patch(f"/v1/domains/{quote(domain_key)}/tools", body)
|
|
122
|
+
return DomainToolsConfig._from_dict(cast(Dict[str, Any], data)["tools_config"])
|
|
123
|
+
|
|
124
|
+
def test(
|
|
125
|
+
self, domain_key: str, tool_name: str, payload: Optional[Dict[str, Any]] = None,
|
|
126
|
+
) -> TestDomainToolResult:
|
|
127
|
+
"""Dispatches a real request to one custom tool's endpoint_url — the
|
|
128
|
+
exact same request shape (headers, auth, `_liya_meta` envelope) an
|
|
129
|
+
agent's real webhook_sender tool call would send — without needing a
|
|
130
|
+
live conversation to trigger it."""
|
|
131
|
+
body: Dict[str, Any] = {"tool_name": tool_name}
|
|
132
|
+
if payload is not None:
|
|
133
|
+
body["payload"] = payload
|
|
134
|
+
data = self._http.post(f"/v1/domains/{quote(domain_key)}/tools/test", body)
|
|
135
|
+
return TestDomainToolResult._from_dict(cast(Dict[str, Any], data))
|
|
@@ -6,6 +6,7 @@ from urllib.parse import quote
|
|
|
6
6
|
|
|
7
7
|
from .._http import HttpClient
|
|
8
8
|
from .run import RunIntentResult, RunStreamEvent, _translate_run_input
|
|
9
|
+
from .domain_tools import DomainToolsResource
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class InlinePromptBinding(TypedDict):
|
|
@@ -296,6 +297,7 @@ class DomainsResource:
|
|
|
296
297
|
self._http = http
|
|
297
298
|
self.intents = DomainIntentsResource(http)
|
|
298
299
|
self.sources = DomainSourcesResource(http)
|
|
300
|
+
self.tools = DomainToolsResource(http)
|
|
299
301
|
|
|
300
302
|
def list(self) -> List[Domain]:
|
|
301
303
|
data = self._http.get("/v1/domains")
|
|
@@ -272,4 +272,77 @@ def test_intents_stream_raises_for_custom_domain_pre_flight_rejection(client):
|
|
|
272
272
|
with pytest.raises(LiyaEngineAPIError) as exc_info:
|
|
273
273
|
list(client.intents.stream(domain="legal-ops", intent="review-contract"))
|
|
274
274
|
assert exc_info.value.code == "STREAMING_NOT_SUPPORTED"
|
|
275
|
-
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
FIXTURE_MASKED_TOOL = {
|
|
278
|
+
"name": "lookup_order", "display_name": "Order Lookup", "description": "Looks up a real order by number",
|
|
279
|
+
"endpoint_url": "https://fernbankoutdoor.com/api/liya-tools/lookup-order", "auth_type": "api_key", "auth_configured": True,
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
@respx.mock
|
|
284
|
+
def test_domain_tools_get(client):
|
|
285
|
+
respx.get(f"{BASE_URL}/v1/domains/shipping-support/tools").mock(
|
|
286
|
+
return_value=httpx.Response(200, json={
|
|
287
|
+
"success": True,
|
|
288
|
+
"data": {
|
|
289
|
+
"platform_tools": [{"name": "document_search", "description": "Search the knowledge base", "enabled": True}],
|
|
290
|
+
"custom_tools": [FIXTURE_MASKED_TOOL],
|
|
291
|
+
"web_search_configured": False,
|
|
292
|
+
},
|
|
293
|
+
})
|
|
294
|
+
)
|
|
295
|
+
config = client.domains.tools.get("shipping-support")
|
|
296
|
+
assert config.platform_tools[0].name == "document_search"
|
|
297
|
+
assert config.custom_tools[0].auth_configured is True
|
|
298
|
+
assert not hasattr(config.custom_tools[0], "auth_value")
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
@respx.mock
|
|
302
|
+
def test_domain_tools_update_replaces_custom_tools(client):
|
|
303
|
+
respx.patch(f"{BASE_URL}/v1/domains/shipping-support/tools").mock(
|
|
304
|
+
return_value=httpx.Response(200, json={
|
|
305
|
+
"success": True,
|
|
306
|
+
"data": {"tools_config": {
|
|
307
|
+
"platform_tools": [],
|
|
308
|
+
"custom_tools": [FIXTURE_MASKED_TOOL],
|
|
309
|
+
"web_search_configured": False,
|
|
310
|
+
}},
|
|
311
|
+
})
|
|
312
|
+
)
|
|
313
|
+
config = client.domains.tools.update(
|
|
314
|
+
"shipping-support",
|
|
315
|
+
custom_tools=[{
|
|
316
|
+
"name": "lookup_order", "display_name": "Order Lookup", "description": "Looks up a real order by number",
|
|
317
|
+
"endpoint_url": "https://fernbankoutdoor.com/api/liya-tools/lookup-order", "auth_type": "api_key",
|
|
318
|
+
"auth_value": "sk_live_...",
|
|
319
|
+
}],
|
|
320
|
+
)
|
|
321
|
+
assert config.custom_tools[0].name == "lookup_order"
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
@respx.mock
|
|
325
|
+
def test_domain_tools_test_dispatches_and_returns_response(client):
|
|
326
|
+
respx.post(f"{BASE_URL}/v1/domains/shipping-support/tools/test").mock(
|
|
327
|
+
return_value=httpx.Response(200, json={
|
|
328
|
+
"success": True,
|
|
329
|
+
"data": {"status_code": 200, "ok": True, "body": {"order_status": "shipped", "eta_days": 2}, "latency_ms": 42},
|
|
330
|
+
})
|
|
331
|
+
)
|
|
332
|
+
result = client.domains.tools.test("shipping-support", "lookup_order", {"order_number": "A1092"})
|
|
333
|
+
assert result.status_code == 200
|
|
334
|
+
assert result.body == {"order_status": "shipped", "eta_days": 2}
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
@respx.mock
|
|
338
|
+
def test_domain_tools_test_raises_for_unknown_tool(client):
|
|
339
|
+
respx.post(f"{BASE_URL}/v1/domains/shipping-support/tools/test").mock(
|
|
340
|
+
return_value=httpx.Response(404, json={
|
|
341
|
+
"success": False,
|
|
342
|
+
"error": {"code": "TOOL_NOT_FOUND", "message": "Custom tool 'does-not-exist' not found."},
|
|
343
|
+
})
|
|
344
|
+
)
|
|
345
|
+
with pytest.raises(LiyaEngineAPIError) as exc_info:
|
|
346
|
+
client.domains.tools.test("shipping-support", "does-not-exist")
|
|
347
|
+
assert exc_info.value.code == "TOOL_NOT_FOUND"
|
|
348
|
+
assert exc_info.value.status == 404
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|