MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / __call__

Method __call__

utils/src/llms.py:381–423  ·  view source on GitHub ↗

Call the agent with prompt arguments. Args: images (list[str]): A list of image file paths. recent (int): The number of recent turns to include. similar (int): The number of similar turns to include. **jinja_args: Additional arguments

(
        self,
        images: list[str] = None,
        recent: int = 0,
        similar: int = 0,
        **jinja_args,
    )

Source from the content-addressed store, hash-verified

379 return f"Role(name={self.name}, model={self.model})"
380
381 def __call__(
382 self,
383 images: list[str] = None,
384 recent: int = 0,
385 similar: int = 0,
386 **jinja_args,
387 ):
388 """
389 Call the agent with prompt arguments.
390
391 Args:
392 images (list[str]): A list of image file paths.
393 recent (int): The number of recent turns to include.
394 similar (int): The number of similar turns to include.
395 **jinja_args: Additional arguments for the Jinja2 template.
396
397 Returns:
398 The response from the role.
399 """
400 if isinstance(images, str):
401 images = [images]
402 assert self.prompt_args == set(jinja_args.keys()), "Invalid arguments"
403 prompt = self.template.render(**jinja_args)
404 history = self.get_history(similar, recent, prompt)
405 history_msg = []
406 for turn in history:
407 history_msg.extend(turn.message)
408
409 response, message = self.llm(
410 prompt,
411 system_message=self.system_message,
412 history=history_msg,
413 images=images,
414 return_message=True,
415 )
416 turn = Turn(
417 id=len(self.history),
418 prompt=prompt,
419 response=response,
420 message=message,
421 images=images,
422 )
423 return self.__post_process__(response, history, turn, similar)
424
425 def __post_process__(
426 self, response: str, history: list[Turn], turn: Turn, similar: int = 0

Callers

nothing calls this directly

Calls 3

get_historyMethod · 0.95
__post_process__Method · 0.95
TurnClass · 0.70

Tested by

no test coverage detected