Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GigaChat Encoder #2

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Add GigaChat Encoder #2

wants to merge 16 commits into from

Conversation

KirillKukharev
Copy link
Owner

Summary

This pull request introduces the GigaChatEncoder class, a new encoder for generating embeddings using the GigaChat API. The implementation includes initialization, embedding generation, and error handling functionalities.

Changes

  • Added GigaChatEncoder class to the project.
  • The encoder class initializes with GigaChat client credentials, name, scope.
  • The call method generates embeddings for a list of documents.
  • Includes error handling and validation for required attributes.

Implementation Details

Initialization:

  • The init method initializes the encoder with optional parameters: name, auth_data, scope, and score_threshold.
  • The method sets default values using EncoderDefault.GIGACHAT if name is not provided.
  • It validates the auth_data and scope parameters, raising ValueError if they are None.
  • Initializes the GigaChat client with provided credentials and scope.

Embedding Generation:

  • The call method takes a list of documents and generates embeddings.
  • Validates that the GigaChat client is initialized.
  • Calls the embeddings method of the GigaChat client to generate embeddings.
  • Extracts and returns the embeddings as a list of lists.
  • Raises a ValueError if the client is not initialized or if the GigaChat call fails.

@Alkons
Copy link

Alkons commented Jun 17, 2024

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants