Co-authored-by: Clément Drouin <clement.drouin@mistral.ai> Co-authored-by: Clément Sirieix <clement.sirieix@mistral.ai> Co-authored-by: Gauthier Guinet <43207538+Gguinet@users.noreply.github.com> Co-authored-by: Kim-Adeline Miguel <kimadeline.miguel@mistral.ai> Co-authored-by: Michel Thomazo <51709227+michelTho@users.noreply.github.com> Co-authored-by: Quentin <torroba.q@gmail.com> Co-authored-by: Simon <80467011+sorgfresser@users.noreply.github.com> Co-authored-by: Simon Van de Kerckhove <simon.vandekerckhove@mistral.ai> Co-authored-by: Vincent G <10739306+VinceOPS@users.noreply.github.com> Co-authored-by: angelapopopo <angele.lenglemetz@mistral.ai> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
16 lines
433 B
Python
16 lines
433 B
Python
from __future__ import annotations
|
|
|
|
from contextlib import contextmanager
|
|
|
|
from vibe.core.llm.backend.factory import BACKEND_FACTORY
|
|
from vibe.core.types import Backend
|
|
|
|
|
|
@contextmanager
|
|
def mock_backend_factory(backend_type: Backend, factory_func):
|
|
original = BACKEND_FACTORY[backend_type]
|
|
try:
|
|
BACKEND_FACTORY[backend_type] = factory_func
|
|
yield
|
|
finally:
|
|
BACKEND_FACTORY[backend_type] = original
|