xrag.embs package#

Submodules#

xrag.embs.chatglmemb module#

class xrag.embs.chatglmemb.ChatGLMEmbeddings(model='embedding-2', reuse_client=True, api_key=None, **kwargs)[source]#

Bases: BaseEmbedding

api_key: str#
classmethod class_name()[source]#

Get the class name, used as a unique ID in serialization.

This provides a key that makes serialization robust against actual class name changes.

Return type:

str

get_general_text_embedding(prompt)[source]#
Return type:

List[float]

model: str#
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'protected_namespaces': ('pydantic_model_',)}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'api_key': FieldInfo(annotation=str, required=False, default=None, description='The ChatGLM API key.'), 'callback_manager': FieldInfo(annotation=CallbackManager, required=False, default_factory=<lambda>, exclude=True), 'embed_batch_size': FieldInfo(annotation=int, required=False, default=10, description='The batch size for embedding calls.', metadata=[Gt(gt=0), Le(le=2048)]), 'model': FieldInfo(annotation=str, required=False, default='embedding-2', description='The ChatGlM model to use. embedding-2'), 'model_name': FieldInfo(annotation=str, required=False, default='unknown', description='The name of the embedding model.'), 'num_workers': FieldInfo(annotation=Union[int, NoneType], required=False, default=None, description='The number of workers to use for async embedding calls.'), 'reuse_client': FieldInfo(annotation=bool, required=False, default=True, description='Reuse the client between requests. When doing anything with large volumes of async API calls, setting this to false can improve stability.')}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

model_post_init(context, /)#

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

Return type:

None

reuse_client: bool#

xrag.embs.embedding module#

xrag.embs.embedding.get_embedding(name)[source]#

Module contents#