Skip to content

Conversation

@vidurkhanal
Copy link
Member

  • Introduce EmbeddingModel, EmbeddingRequest, and EmbeddingResponse types.
  • Add Embeds async trait for embedding functionality.
  • Implement Embeds for AmazonBedrockProvider with parallel, retryable embedding requests.
  • Add do_embed async method to AIProvider.
  • Add embed module with retry logic and request struct.
  • Add futures as a workspace dependency.
  • Provide Default impls for OpenAIProvider and CohereProvider.
  • Extend ResponseGeneratorError with new error variants for embedding.
  • Update module exports and imports accordingly.

- Introduce `EmbeddingModel`, `EmbeddingRequest`, and `EmbeddingResponse` types.
- Add `Embeds` async trait for embedding functionality.
- Implement `Embeds` for `AmazonBedrockProvider` with parallel, retryable embedding requests.
- Add `do_embed` async method to `AIProvider`.
- Add `embed` module with retry logic and request struct.
- Add `futures` as a workspace dependency.
- Provide `Default` impls for `OpenAIProvider` and `CohereProvider`.
- Extend `ResponseGeneratorError` with new error variants for embedding.
- Update module exports and imports accordingly.
@vidurkhanal vidurkhanal marked this pull request as ready for review January 22, 2026 03:59
@vidurkhanal vidurkhanal force-pushed the feat/embed-in-umem-ai branch from bd3d023 to 10d9629 Compare January 22, 2026 03:59
…ngRequest API

- Implement embedding support for Amazon Bedrock provider, including request routing and response handling.
- Refactor `EmbeddingRequest` with `TypedBuilder`, add fields for dimensions and normalization, and improve header handling.
- Update error handling to use `meta()` for Bedrock errors and rename `BedrockRerankInvokeError` to `BedrockInvokeError`.
- Add embedding test for Amazon Bedrock provider.
@vidurkhanal vidurkhanal force-pushed the feat/embed-in-umem-ai branch from 10d9629 to 19781b2 Compare January 22, 2026 04:00
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 22, 2026

Greptile Summary

This PR adds embedding API support to the umem_ai crate with Amazon Bedrock as the initial provider implementation. The implementation introduces parallel, retryable embedding requests with proper concurrency control using semaphores.

Key Changes:

  • Added EmbeddingModel, EmbeddingRequest, and EmbeddingResponse types for the embedding API
  • Implemented Embeds trait with Amazon Bedrock provider support using parallel requests
  • Added retry logic with exponential backoff for embedding operations
  • Enhanced error handling to use .meta() for better error messages from AWS SDK
  • Added Default implementations for OpenAIProvider and CohereProvider for easier instantiation
  • Introduced new error variants: BedrockInvokeError and InternalServerError

Issues Found:

  • Minor typo in error message ("makng" instead of "making") in amazon_bedrock.rs:477
  • The custom_headers field in EmbeddingRequest is defined but never used in the implementation

Confidence Score: 4/5

  • This PR is safe to merge with one minor typo correction needed
  • The implementation is well-structured with proper error handling, concurrency control, and retry logic. The parallel embedding requests use semaphores correctly to limit concurrent operations. Error handling has been improved to use .meta() for better diagnostics. Only one syntax error (typo) was found that needs correction. The unused custom_headers field is a minor issue that doesn't affect functionality.
  • Pay attention to crates/umem_ai/src/providers/amazon_bedrock.rs for the typo fix

Important Files Changed

Filename Overview
crates/umem_ai/src/providers/amazon_bedrock.rs added Embeds trait implementation with parallel embedding requests and semaphore-based concurrency control, changed error handling to use .meta() for better error messages, added default() method (minor typo in error message)
crates/umem_ai/src/response_generators/embed.rs new file introducing embedding functionality with retry logic, timeout handling, and configurable request parameters (custom_headers field unused)
crates/umem_ai/src/lib.rs added EmbeddingModel struct, Embeds trait, and do_embed method to AIProvider enum

Sequence Diagram

sequenceDiagram
    participant Client
    participant embed_fn as embed()
    participant AIProvider
    participant AmazonBedrockProvider
    participant Semaphore
    participant BedrockRuntime as AWS Bedrock API
    
    Client->>embed_fn: EmbeddingRequest
    embed_fn->>embed_fn: Setup retry logic<br/>(ExponentialBuilder)
    
    loop Retry up to max_retries
        embed_fn->>AIProvider: do_embed(request)
        AIProvider->>AmazonBedrockProvider: embed(request)
        
        AmazonBedrockProvider->>AmazonBedrockProvider: Validate input is not empty
        AmazonBedrockProvider->>Semaphore: Create with max_parallels
        
        par Parallel embedding requests
            loop For each input text
                AmazonBedrockProvider->>Semaphore: acquire_owned()
                Semaphore-->>AmazonBedrockProvider: permit
                AmazonBedrockProvider->>BedrockRuntime: invoke_model()<br/>(inputText, dimensions, normalize)
                BedrockRuntime-->>AmazonBedrockProvider: InvokeModelOutput
                AmazonBedrockProvider->>AmazonBedrockProvider: Drop permit
            end
        end
        
        AmazonBedrockProvider->>AmazonBedrockProvider: join_all(handles)
        AmazonBedrockProvider->>AmazonBedrockProvider: Deserialize responses
        AmazonBedrockProvider->>AmazonBedrockProvider: Extract embeddings
        AmazonBedrockProvider-->>AIProvider: EmbeddingResponse
        AIProvider-->>embed_fn: EmbeddingResponse
        
        alt Success
            embed_fn-->>Client: EmbeddingResponse
        else Retryable Error
            embed_fn->>embed_fn: Wait (exponential backoff)
        end
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@Sang-it Sang-it merged commit b4f5a63 into main Jan 22, 2026
1 check passed
@Sang-it Sang-it deleted the feat/embed-in-umem-ai branch January 22, 2026 04:20
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.

3 participants