mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-03 06:51:00 +02:00
fix: wire variant into text-completion integration test mocks (#1008)
Tests using MagicMock processors need the variant, thinking mode, and _build_kwargs/_extract_content methods bound to work with the new variant-based API kwargs construction.
This commit is contained in:
parent
f20b50cfb2
commit
656ca430b9
2 changed files with 26 additions and 1 deletions
|
|
@ -11,6 +11,7 @@ from openai.types.chat import ChatCompletionChunk
|
|||
from openai.types.chat.chat_completion_chunk import Choice as StreamChoice, ChoiceDelta
|
||||
|
||||
from trustgraph.model.text_completion.openai.llm import Processor
|
||||
from trustgraph.model.text_completion.openai.variants import get_variant
|
||||
from trustgraph.base import LlmChunk
|
||||
from tests.utils.streaming_assertions import (
|
||||
assert_streaming_chunks_valid,
|
||||
|
|
@ -18,6 +19,14 @@ from tests.utils.streaming_assertions import (
|
|||
)
|
||||
|
||||
|
||||
def _wire_variant(processor):
|
||||
"""Attach variant methods to a MagicMock processor."""
|
||||
processor.variant = get_variant("openai")
|
||||
processor.thinking = "off"
|
||||
processor._build_kwargs = Processor._build_kwargs.__get__(processor, Processor)
|
||||
processor._extract_content = Processor._extract_content.__get__(processor, Processor)
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
class TestTextCompletionStreaming:
|
||||
"""Integration tests for Text Completion streaming"""
|
||||
|
|
@ -69,6 +78,7 @@ class TestTextCompletionStreaming:
|
|||
processor.generate_content_stream = Processor.generate_content_stream.__get__(
|
||||
processor, Processor
|
||||
)
|
||||
_wire_variant(processor)
|
||||
|
||||
return processor
|
||||
|
||||
|
|
@ -190,6 +200,7 @@ class TestTextCompletionStreaming:
|
|||
processor.generate_content_stream = Processor.generate_content_stream.__get__(
|
||||
processor, Processor
|
||||
)
|
||||
_wire_variant(processor)
|
||||
|
||||
# Act
|
||||
chunks = []
|
||||
|
|
@ -223,6 +234,7 @@ class TestTextCompletionStreaming:
|
|||
processor.generate_content_stream = Processor.generate_content_stream.__get__(
|
||||
processor, Processor
|
||||
)
|
||||
_wire_variant(processor)
|
||||
|
||||
# Act
|
||||
chunks = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue