Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/uipath-platform/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath-platform"
version = "0.2.33"
version = "0.2.33.post1"
description = "HTTP client library for programmatic access to UiPath Platform"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
EscalationMemoryIngestRequest,
EscalationMemoryMatch,
EscalationMemorySearchResponse,
FieldMatching,
FieldSettings,
MemoryMatch,
MemoryMatchField,
Expand All @@ -24,6 +25,7 @@
"EscalationMemoryIngestRequest",
"EscalationMemoryMatch",
"EscalationMemorySearchResponse",
"FieldMatching",
"FieldSettings",
"MemoryMatch",
"MemoryMatchField",
Expand Down
18 changes: 18 additions & 0 deletions packages/uipath-platform/src/uipath/platform/memory/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ class SearchMode(str, Enum):
Semantic = "Semantic"


class FieldMatching(str, Enum):
"""How per-field matches combine: any field passes (Or) or every field passes (And)."""

Or = "Or"
And = "And"

@classmethod
def _missing_(cls, value: object) -> Optional["FieldMatching"]:
if isinstance(value, str):
for member in cls:
if member.value.lower() == value.lower():
return member
return None


# ── Shared field models (used by both ECS and LLMOps) ─────────────────


Expand Down Expand Up @@ -51,6 +66,9 @@ class SearchSettings(BaseModel):
threshold: float = Field(default=0.0, alias="threshold", ge=0.0, le=1.0)
result_count: int = Field(default=1, alias="resultCount", ge=1, le=10)
search_mode: SearchMode = Field(..., alias="searchMode")
field_matching: FieldMatching = Field(
default=FieldMatching.Or, alias="fieldMatching"
)


class MemoryMatchField(BaseModel):
Expand Down
69 changes: 69 additions & 0 deletions packages/uipath-platform/tests/services/test_memory_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import json

import pytest
from pydantic import ValidationError
from pytest_httpx import HTTPXMock

from uipath.platform import UiPathApiConfig, UiPathExecutionContext
from uipath.platform.memory import (
EscalationMemoryIngestRequest,
EscalationMemorySearchResponse,
FieldMatching,
MemoryMatch,
MemoryMatchField,
MemorySearchRequest,
Expand Down Expand Up @@ -293,8 +295,75 @@ def test_search_memory(
body = json.loads(sent.content)
assert body["fields"][0]["keyPath"] == ["input"]
assert body["settings"]["searchMode"] == "Hybrid"
assert body["settings"]["fieldMatching"] == "Or"
assert body["definitionSystemPrompt"] == "You are a helpful assistant."

@pytest.mark.parametrize(
("raw", "expected"),
[
("or", FieldMatching.Or),
("and", FieldMatching.And),
("Or", FieldMatching.Or),
("And", FieldMatching.And),
("AND", FieldMatching.And),
(FieldMatching.And, FieldMatching.And),
],
)
def test_search_settings_parse_field_matching_case_insensitively(
self, raw: str | FieldMatching, expected: FieldMatching
) -> None:
settings = SearchSettings.model_validate(
{"searchMode": "Hybrid", "fieldMatching": raw}
)

assert settings.field_matching is expected

def test_search_settings_default_field_matching_is_or(self) -> None:
settings = SearchSettings.model_validate({"searchMode": "Hybrid"})

assert settings.field_matching is FieldMatching.Or

@pytest.mark.parametrize("raw", ["xor", "", 1, None])
def test_search_settings_reject_unknown_field_matching(
self, raw: object
) -> None:
with pytest.raises(ValidationError):
SearchSettings.model_validate(
{"searchMode": "Hybrid", "fieldMatching": raw}
)

def test_search_sends_configured_field_matching(
self,
httpx_mock: HTTPXMock,
service: MemoryService,
base_url: str,
org: str,
tenant: str,
) -> None:
memory_space_id = "aaaa-bbbb-cccc-dddd"
httpx_mock.add_response(
url=f"{base_url}{org}{tenant}/llmopstenant_/api/Agent/memory/{memory_space_id}/search",
status_code=200,
json=SAMPLE_SEARCH_RESPONSE,
)

request = MemorySearchRequest(
fields=[SearchField(key_path=["input"], value="Northwind")],
settings=SearchSettings(
threshold=0.8,
result_count=1,
search_mode=SearchMode.Hybrid,
field_matching=FieldMatching.And,
),
)

service.search(memory_space_id=memory_space_id, request=request)

sent = httpx_mock.get_request()
assert sent is not None
body = json.loads(sent.content)
assert body["settings"]["fieldMatching"] == "And"

def test_search_sends_folder_header(
self,
httpx_mock: HTTPXMock,
Expand Down
4 changes: 2 additions & 2 deletions packages/uipath-platform/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/uipath/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading