mirror of
https://github.com/mudler/LocalAI.git
synced 2026-10-28 09:08:54 -04: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>
(cherry picked from commit ff0130fa89)
This commit is contained in:
1 parent
651c8da4d6
commit
5e63cc1ec1
2 files changed
+25
No files matched your search
@@ -762,6 +762,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