memoryscope.core.models.dummy_generation_model

class memoryscope.core.models.dummy_generation_model.DummyGenerationModel(model_name: str, module_name: str, timeout: int | None = None, max_retries: int = 3, retry_interval: float = 1.0, kwargs_filter: bool = True, raise_exception: bool = True, **kwargs)[source]

Bases: BaseModel

The DummyGenerationModel class serves as a placeholder model for generating responses. It processes input prompts or sequences of messages, adapting them into a structure compatible with chat interfaces. It also facilitates the generation of mock (dummy) responses for testing, supporting both immediate and streamed output.

m_type: ModelEnum = 'generation_model'
before_call(model_response: ModelResponse, **kwargs)[source]

Prepares the input data before making a call to the language model. It accepts either a ‘prompt’ directly or a list of ‘messages’. If ‘prompt’ is provided, it sets the data accordingly. If ‘messages’ are provided, it constructs a list of ChatMessage objects from the list. Raises an error if neither ‘prompt’ nor ‘messages’ are supplied.

Parameters:
  • model_response – model_response

  • **kwargs – Arbitrary keyword arguments including ‘prompt’ and ‘messages’.

Raises:

RuntimeError – When both ‘prompt’ and ‘messages’ inputs are not provided.

after_call(model_response: ModelResponse, stream: bool = False, **kwargs) ModelResponse | Generator[ModelResponse, None, None][source]

Processes the model’s response post-call, optionally streaming the output or returning it as a whole.

This method modifies the input model_response by resetting its message content and, based on the stream parameter, either yields the response in a generated stream or returns the complete response directly.

Parameters:
  • model_response (ModelResponse) – The initial response object to be processed.

  • stream (bool, optional) – Flag indicating whether to stream the response. Defaults to False.

  • **kwargs – Additional keyword arguments (not used in this implementation).

Returns:

If stream is True, a generator yielding updated ModelResponse objects;

otherwise, a modified ModelResponse object with the complete content.

Return type:

ModelResponse | ModelResponseGen

model_name: str
module_name: str
timeout: int
max_retries: int
retry_interval: float
kwargs_filter: bool
raise_exception: bool
context: MemoryscopeContext
kwargs: dict