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

feat: Add GigaChat Encoder #332

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

Conversation

KirillKukharev
Copy link

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.
  • Add unit tests and docs

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.

@KirillKukharev KirillKukharev changed the title Add GigaChat embedding Add GigaChat encoder Jun 18, 2024
@KirillKukharev KirillKukharev changed the title Add GigaChat encoder Add GigaChat Encoder Jun 18, 2024
@KirillKukharev KirillKukharev changed the title Add GigaChat Encoder feat: Add GigaChat Encoder Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant