MCPcopy Create free account
hub / github.com/AQ-MedAI/MedMemoryBench / _queue_push

Method _queue_push

methods/MIRIX/mirix/interface.py:331–375  ·  view source on GitHub ↗

Wrapper around self.buffer.queue.put() that ensures the types are safe Data will be in the format: { "message_obj": ... "message_string": ... }

(self, message_api: Union[str, dict], message_obj: Union[Message, None])

Source from the content-addressed store, hash-verified

329 self.debug = debug
330
331 def _queue_push(self, message_api: Union[str, dict], message_obj: Union[Message, None]):
332 """Wrapper around self.buffer.queue.put() that ensures the types are safe
333
334 Data will be in the format: {
335 "message_obj": ...
336 "message_string": ...
337 }
338 """
339
340 # Check the string first
341
342 if isinstance(message_api, str):
343 # check that it's the stop word
344 if message_api == "STOP":
345 assert message_obj is None
346 self.buffer.put(
347 {
348 "message_api": message_api,
349 "message_obj": None,
350 }
351 )
352 else:
353 raise ValueError(f"Unrecognized string pushed to buffer: {message_api}")
354
355 elif isinstance(message_api, dict):
356 # check if it's the error message style
357 if len(message_api.keys()) == 1 and "internal_error" in message_api:
358 assert message_obj is None
359 self.buffer.put(
360 {
361 "message_api": message_api,
362 "message_obj": None,
363 }
364 )
365 else:
366 assert message_obj is not None, message_api
367 self.buffer.put(
368 {
369 "message_api": message_api,
370 "message_obj": message_obj,
371 }
372 )
373
374 else:
375 raise ValueError(f"Unrecognized type pushed to buffer: {type(message_api)}")
376
377 def to_list(self, style: Literal["obj", "api"] = "obj"):
378 """Convert queue to a list (empties it out at the same time)"""

Callers 5

step_yieldMethod · 0.95
errorMethod · 0.95
internal_monologueMethod · 0.95
assistant_messageMethod · 0.95
function_messageMethod · 0.95

Calls 2

putMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected