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.3.6"
version = "0.3.7"
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 @@ -72,14 +72,19 @@ class SearchSettings(BaseModel):


class MemoryMatchField(BaseModel):
"""A field within a search result, with scoring details."""
"""A field within a search result, with scoring details.

``semantic_score`` is the field's vector similarity, as distinct from
``score``.
"""

model_config = ConfigDict(populate_by_name=True)

key_path: List[str] = Field(..., alias="keyPath")
value: str = Field(..., alias="value")
weight: float = Field(..., alias="weight")
score: float = Field(..., alias="score")
semantic_score: Optional[float] = Field(None, alias="semanticScore")
weighted_score: float = Field(..., alias="weightedScore")


Expand Down
27 changes: 27 additions & 0 deletions packages/uipath-platform/tests/services/test_memory_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def service(
"value": "What is the capital of France?",
"weight": 1.0,
"score": 0.95,
"semanticScore": 0.91,
"weightedScore": 0.95,
}
],
Expand Down Expand Up @@ -284,6 +285,7 @@ def test_search_memory(
assert result.results[0].memory_item_id == "item-001"
assert result.results[0].score == 0.95
assert isinstance(result.results[0].fields[0], MemoryMatchField)
assert result.results[0].fields[0].semantic_score == 0.91
assert (
result.system_prompt_injection
== "Based on past interactions: Paris is the capital."
Expand All @@ -298,6 +300,31 @@ def test_search_memory(
assert body["settings"]["fieldMatching"] == "Or"
assert body["definitionSystemPrompt"] == "You are a helpful assistant."

def test_search_response_keeps_field_semantic_score_in_dump(self) -> None:
response = MemorySearchResponse.model_validate(SAMPLE_SEARCH_RESPONSE)

dumped = response.model_dump(by_alias=True, exclude_none=True)

field = dumped["results"][0]["fields"][0]
assert field["semanticScore"] == 0.91
assert field["score"] == 0.95

def test_search_response_field_semantic_score_is_optional(self) -> None:
field = MemoryMatchField.model_validate(
{
"keyPath": ["agent-input", "topic"],
"value": "python",
"weight": 1.0,
"score": 0.5,
"weightedScore": 0.5,
}
)

assert field.semantic_score is None
assert "semanticScore" not in field.model_dump(
by_alias=True, exclude_none=True
)

@pytest.mark.parametrize(
("raw", "expected"),
[
Expand Down
2 changes: 1 addition & 1 deletion packages/uipath-platform/uv.lock

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

2 changes: 1 addition & 1 deletion packages/uipath/uv.lock

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

Loading