test(fase2): re-base synthetic client on layered client so chat middleware fires
This commit is contained in:
parent
6ef4efcdd1
commit
bf0bbfffae
1 changed files with 12 additions and 3 deletions
|
|
@ -19,13 +19,20 @@ from agent_framework import (
|
|||
Message,
|
||||
UsageDetails,
|
||||
)
|
||||
from agent_framework_openai import OpenAIChatCompletionClient
|
||||
|
||||
from portfolio_optimiser.verdicts import VerdictStore, seed_store
|
||||
|
||||
|
||||
class SyntheticUsageChatClient(BaseChatClient):
|
||||
class SyntheticUsageChatClient(OpenAIChatCompletionClient):
|
||||
"""Network-free chat client returning scripted/default replies WITH a synthetic
|
||||
``UsageDetails`` (``total_token_count``), so strict usage accounting does not hard-fail."""
|
||||
``UsageDetails`` (``total_token_count``), so strict usage accounting does not hard-fail.
|
||||
|
||||
Subclasses the LAYERED ``OpenAIChatCompletionClient`` (not the minimal ``BaseChatClient``)
|
||||
so it inherits the ``ChatMiddlewareLayer`` — a ``ChatMiddleware`` attached to an agent
|
||||
backed by the minimal base would silently no-op (verified). Construction is offline
|
||||
(loopback ``base_url``, dummy key); the ``_inner_get_response`` override intercepts the
|
||||
raw call before any HTTP, so no network is touched."""
|
||||
|
||||
OTEL_PROVIDER_NAME = "synthetic"
|
||||
|
||||
|
|
@ -36,7 +43,9 @@ class SyntheticUsageChatClient(BaseChatClient):
|
|||
default_reply: str = "ok",
|
||||
tokens_per_reply: int = 8,
|
||||
) -> None:
|
||||
super().__init__()
|
||||
super().__init__(
|
||||
model="synthetic", api_key="synthetic", base_url="http://127.0.0.1:9/v1"
|
||||
)
|
||||
self._scripted = list(scripted or [])
|
||||
self._idx = 0
|
||||
self._default = default_reply
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue