-
Notifications
You must be signed in to change notification settings - Fork 0
feat(umem_ai): add embedding API and provider support #64
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
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
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
|
There was a problem hiding this 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
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
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.