mirror of
https://github.com/mudler/LocalAI.git
synced 2026-11-03 02:54:45 -05:00
test(vllm): isolate streaming parser fixtures
Mock the request constructor so fake parser tests can run on older vLLM profiles without ParserManager. Document the streaming version requirement and fallback behavior. Signed-off-by: pos-ei-don <1822533+pos-ei-don@users.noreply.github.com>
This commit is contained in:
1 parent
5392eb813e
commit
ff0130fa89
2 files changed
+25
No files matched your search
@@ -679,6 +679,24 @@ class TestStreamingReasoningSplit(unittest.TestCase):
|
||||
THINK = ["Let me ", "count the ", "primes.", "</think>"]
|
||||
ANSWER = ["There are ", "37 primes."]
|
||||
|
||||
def setUp(self):
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import patch
|
||||
import backend
|
||||
|
||||
def parser_request(model, messages, tools=None):
|
||||
return SimpleNamespace(
|
||||
model=model, messages=messages,
|
||||
tools=[SimpleNamespace(function=SimpleNamespace(**tool["function"]))
|
||||
for tool in tools] if tools else None,
|
||||
)
|
||||
|
||||
# These fake-parser tests also run on backend profiles whose vLLM
|
||||
# predates ParserManager and therefore has no _ParserRequest import.
|
||||
request_patch = patch.object(backend, "_ParserRequest", parser_request, create=True)
|
||||
request_patch.start()
|
||||
self.addCleanup(request_patch.stop)
|
||||
|
||||
class _DeltaMsg:
|
||||
def __init__(self, content=None, reasoning=None, tool_calls=None):
|
||||
self.content = content
|
||||
|
||||
Reference in new issue
Block a user