fixes to azure ai search init, samples (#5021)

This commit is contained in:
Eduard van Valkenburg
2026-04-01 11:59:52 +02:00
committed by GitHub
Unverified
parent e43fc8ccec
commit 2a8c3e2dcf
9 changed files with 333 additions and 53 deletions
@@ -808,22 +808,21 @@ class SupportsFileSearchTool(Protocol):
# region SupportsGetEmbeddings Protocol
# Contravariant TypeVars for the Protocol
# TypeVars for the Protocol
EmbeddingInputContraT = TypeVar(
"EmbeddingInputContraT",
default="str",
contravariant=True,
)
EmbeddingOptionsContraT = TypeVar(
"EmbeddingOptionsContraT",
EmbeddingProtocolOptionsT = TypeVar(
"EmbeddingProtocolOptionsT",
bound=TypedDict, # type: ignore[valid-type]
default="EmbeddingGenerationOptions",
contravariant=True,
)
@runtime_checkable
class SupportsGetEmbeddings(Protocol[EmbeddingInputContraT, EmbeddingT, EmbeddingOptionsContraT]):
class SupportsGetEmbeddings(Protocol[EmbeddingInputContraT, EmbeddingT, EmbeddingProtocolOptionsT]):
"""Protocol for an embedding client that can generate embeddings.
This protocol enables duck-typing for embedding generation. Any class that
@@ -850,8 +849,8 @@ class SupportsGetEmbeddings(Protocol[EmbeddingInputContraT, EmbeddingT, Embeddin
self,
values: Sequence[EmbeddingInputContraT],
*,
options: EmbeddingOptionsContraT | None = None,
) -> Awaitable[GeneratedEmbeddings[EmbeddingT]]:
options: EmbeddingProtocolOptionsT | None = None,
) -> Awaitable[GeneratedEmbeddings[EmbeddingT, EmbeddingProtocolOptionsT]]:
"""Generate embeddings for the given values.
Args:
@@ -96,6 +96,7 @@ class ConversationSplitter(Protocol):
# Fallback: split at last user message
return EvalItem._split_last_turn_static(conversation)
item.split_messages(split=split_before_memory)
"""
@@ -468,10 +469,7 @@ class EvalResults:
"""
if not self.all_passed:
errored = (self.result_counts or {}).get("errored", 0)
detail = msg or (
f"Eval run {self.run_id} {self.status}: "
f"{self.passed} passed, {self.failed} failed."
)
detail = msg or (f"Eval run {self.run_id} {self.status}: {self.passed} passed, {self.failed} failed.")
if errored:
detail += f" {errored} errored."
if self.report_url:
@@ -1188,8 +1186,7 @@ def _coerce_result(value: Any, check_name: str) -> CheckResult:
score = float(d["score"])
except (TypeError, ValueError) as exc:
raise TypeError(
f"Function evaluator '{check_name}' returned dict with non-numeric 'score' value:"
f" {d['score']!r}"
f"Function evaluator '{check_name}' returned dict with non-numeric 'score' value: {d['score']!r}"
) from exc
# Honour an explicit 'passed' override; otherwise threshold-based.
passed = bool(d["passed"]) if "passed" in d else score >= float(d.get("threshold", 0.5))