quackamollie.model_manager.langchain.langchain_model_manager module

class quackamollie.model_manager.langchain.langchain_model_manager.LangchainQuackamollieModelManager[source]

Bases: MetaQuackamollieModelManager

Model manager managed by the QuackamollieModelManagerRegistry and serving models using Langchain

LANGCHAIN_ENTRYPOINT_GROUP: str = 'quackamollie.model.langchain'
_abc_impl = <_abc._abc_data object>
_entrypoint_model_dict: Dict[str, Type[MetaLangchainQuackamollieModel]] | None = None
families: List[ModelFamilyIcon] = [ModelFamilyIcon.LANGCHAIN]
async classmethod get_entrypoint_model_dict() Dict[str, Type[MetaLangchainQuackamollieModel]] | None[source]
async classmethod get_model_class(model_name: str) Type[MetaLangchainQuackamollieModel] | None[source]

Get the model class from the model name

Parameters:

model_name (str) – Name of the model as listed by cls.get_model_list

Returns:

A subclass of MetaQuackamollieModel

Return type:

Optional[Type[MetaLangchainQuackamollieModel]]

async classmethod get_model_families() Dict[str, List[ModelFamilyIcon]][source]

Discover the models families available for the model manager at runtime asynchronously

Returns:

A dict with values the list of families indexed by model name

Return type:

Dict[str, List[ModelFamilyIcon]]

async classmethod get_model_list() List[str] | None[source]

Discover the models available for the model manager at runtime asynchronously

Returns:

A list of available models for the model manager

Return type:

List[str]

classmethod parse_chat_history(chat_messages: List[ChatMessage] | None) List[Tuple[str, str]][source]

Parse the chat history given as a list of ChatMessage from the database model to a list compatible with the model manager’s models.

Parameters:
  • chat_messages – A list of ChatMessage from the database model

  • chat_messages – Optional[List[ChatMessage]]

Returns:

A list of messages formatted to be compatible with the model manager’s models.

Return type:

List[Tuple[str, str]]

classmethod reset()[source]

Reset the model manager dynamic fields to force reloading models. Be careful if used asynchronously