mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 14:25:00 +00:00
test: add reasoning attribute handling to MockStreamingChunk
This commit is contained in:
parent
a15d10ea1e
commit
0df959cf68
1 changed files with 16 additions and 2 deletions
|
@ -90,7 +90,7 @@ class TestReasoning(unittest.TestCase):
|
||||||
|
|
||||||
# Mock streaming response chunks
|
# Mock streaming response chunks
|
||||||
class MockStreamingChunk:
|
class MockStreamingChunk:
|
||||||
def __init__(self, content=None, reasoning_content=None, finish_reason=None):
|
def __init__(self, content=None, reasoning_content=None, reasoning=None, finish_reason=None):
|
||||||
self.choices = [MagicMock()]
|
self.choices = [MagicMock()]
|
||||||
self.choices[0].delta = MagicMock()
|
self.choices[0].delta = MagicMock()
|
||||||
self.choices[0].finish_reason = finish_reason
|
self.choices[0].finish_reason = finish_reason
|
||||||
|
@ -109,6 +109,13 @@ class TestReasoning(unittest.TestCase):
|
||||||
# Need to handle attribute access that would raise AttributeError
|
# Need to handle attribute access that would raise AttributeError
|
||||||
delattr(self.choices[0].delta, "reasoning_content")
|
delattr(self.choices[0].delta, "reasoning_content")
|
||||||
|
|
||||||
|
# Set reasoning if provided
|
||||||
|
if reasoning is not None:
|
||||||
|
self.choices[0].delta.reasoning = reasoning
|
||||||
|
else:
|
||||||
|
# Need to handle attribute access that would raise AttributeError
|
||||||
|
delattr(self.choices[0].delta, "reasoning")
|
||||||
|
|
||||||
# Create chunks to simulate streaming
|
# Create chunks to simulate streaming
|
||||||
chunks = [
|
chunks = [
|
||||||
# First chunk with reasoning content starts the tag
|
# First chunk with reasoning content starts the tag
|
||||||
|
@ -264,7 +271,7 @@ class TestReasoning(unittest.TestCase):
|
||||||
|
|
||||||
# Mock streaming response chunks
|
# Mock streaming response chunks
|
||||||
class MockStreamingChunk:
|
class MockStreamingChunk:
|
||||||
def __init__(self, content=None, reasoning_content=None, finish_reason=None):
|
def __init__(self, content=None, reasoning_content=None, reasoning=None, finish_reason=None):
|
||||||
self.choices = [MagicMock()]
|
self.choices = [MagicMock()]
|
||||||
self.choices[0].delta = MagicMock()
|
self.choices[0].delta = MagicMock()
|
||||||
self.choices[0].finish_reason = finish_reason
|
self.choices[0].finish_reason = finish_reason
|
||||||
|
@ -283,6 +290,13 @@ class TestReasoning(unittest.TestCase):
|
||||||
# Need to handle attribute access that would raise AttributeError
|
# Need to handle attribute access that would raise AttributeError
|
||||||
delattr(self.choices[0].delta, "reasoning_content")
|
delattr(self.choices[0].delta, "reasoning_content")
|
||||||
|
|
||||||
|
# Set reasoning if provided
|
||||||
|
if reasoning is not None:
|
||||||
|
self.choices[0].delta.reasoning = reasoning
|
||||||
|
else:
|
||||||
|
# Need to handle attribute access that would raise AttributeError
|
||||||
|
delattr(self.choices[0].delta, "reasoning")
|
||||||
|
|
||||||
# Create chunks to simulate streaming with think tags
|
# Create chunks to simulate streaming with think tags
|
||||||
chunks = [
|
chunks = [
|
||||||
# Start with open think tag
|
# Start with open think tag
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue