- Delete client.dump_openai_response (and its import json): never called from any production path (connect_node, text_gen_node, image_to_text_node, routes, __init__); existed only as a debugging aid. - Delete its test (test_dump_openai_response_branches in test_client_full.py) and the now-orphaned `import json` in that file. - Delete make_response_with_output_text / make_response_with_output_items from tests/helpers/fakes.py: defined in the initial test scaffolding commit but never imported or referenced by any test module. All 68 tests pass; branch coverage holds at 96.93 % (> 90 % required). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
37 lines
811 B
Python
37 lines
811 B
Python
from __future__ import annotations
|
|
|
|
from types import SimpleNamespace
|
|
from typing import Any
|
|
|
|
import numpy as np
|
|
|
|
|
|
def ns(**kwargs) -> SimpleNamespace:
|
|
return SimpleNamespace(**kwargs)
|
|
|
|
|
|
def make_chat_completion(content: Any) -> SimpleNamespace:
|
|
return ns(choices=[ns(message=ns(content=content))])
|
|
|
|
|
|
class FakeTensor:
|
|
def __init__(self, array: np.ndarray):
|
|
self._array = np.asarray(array, dtype=np.float32)
|
|
|
|
@property
|
|
def ndim(self) -> int:
|
|
return self._array.ndim
|
|
|
|
@property
|
|
def shape(self) -> tuple[int, ...]:
|
|
return self._array.shape
|
|
|
|
def cpu(self) -> "FakeTensor":
|
|
return self
|
|
|
|
def numpy(self) -> np.ndarray:
|
|
return self._array
|
|
|
|
def __getitem__(self, index: int) -> "FakeTensor":
|
|
return FakeTensor(self._array[index])
|