feat(umem_ai): add embedding API and provider support#64
Merged
Conversation
- 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.
bd3d023 to
10d9629
Compare
…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.
10d9629 to
19781b2
Compare
Contributor
Greptile SummaryThis PR adds embedding API support to the Key Changes:
Issues Found:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
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
|
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Sang-it
approved these changes
Jan 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
EmbeddingModel,EmbeddingRequest, andEmbeddingResponsetypes.Embedsasync trait for embedding functionality.EmbedsforAmazonBedrockProviderwith parallel, retryable embedding requests.do_embedasync method toAIProvider.embedmodule with retry logic and request struct.futuresas a workspace dependency.Defaultimpls forOpenAIProviderandCohereProvider.ResponseGeneratorErrorwith new error variants for embedding.