Using Langchain4j with OpenSearch Service Collections

0

Wonder if it is possible to use Langchain4j with OpenSearch Service Collections. Based off of the Langchain4j documentation there is a way to use the OpenSearch Embedding store: https://github.com/langchain4j/langchain4j-examples/blob/main/opensearch-example/src/main/java/OpenSearchEmbeddingStoreExample.java.

I am trying to do this, but with the Amazon OpenSearch service Collections. I have a collection and index created. Right now, here is a snippet of my code from lambda

EmbeddingStore<TextSegment> embeddingStore = OpenSearchEmbeddingStore.builder()
                    .serverUrl(<MY_OPENSEARCH_ENDPOINTt>)
                    .build();

I have no problem creating and building the embedding store, but once I try to do embeddingStore.add(), I am getting this error: Request failed: [Forbidden] 403 Forbidden. What permissions do I need to have within my Collection and Lambda in order to allow me to add text to the embeddingStore?

Within my lambda, I have these permissions: - Effect: Allow Action: - aoss:* Resource: "*"

asked a month ago56 views
1 Answer
2

Hello,

Upon examining the code, I cannot see any provisions for sending a signed request. As you are encountering a 403 error, which typically indicates an authentication issue, rather than the library being incapable of sending a signed request, I would kindly request that you verify your ability to send a signed request using Langchain4j.

Signed Request to OpenSearch Serverless: https://docs.aws.amazon.com/opensearch-service/latest/developerguide/serverless-clients.html

Additionally, I have observed that there is already an open feature request to support OpenSearch Serverless: https://github.com/langchain4j/langchain4j/issues/1324

Furthermore, I have found an online documentation resource that demonstrates how to establish a connection with Python: https://caylent.com/blog/building-a-rag-with-open-search-serverless-and-lang-chain

Thank you!

AWS
SUPPORT ENGINEER
answered a month ago
profile picture
EXPERT
reviewed a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions