Oi @taigofranca !!
Welcome to our community
I believe that the issue here is that by default, BedrockEmbeddings
from langchain will grab the credentials from ~/.aws/credentials
, while Weaviate will accept those in headers.
So now you need to make sure that you pass a working langchain embeddings object, like so:
from langchain_aws import BedrockEmbeddings
embeddings = BedrockEmbeddings(model_id="amazon.titan-embed-text-v2:0", credentials_profile_name="my_cool_aws_profile")
result = embeddings.embed_query("This is a test")
print(result)
I was able to run a basic insert/generate with this code, but this will only Weaviate, and rely on the credentials you pass at the client instantiation
from weaviate.classes.config import Configure
client.collections.delete("DemoCollection")
collection = client.collections.create(
"DemoCollection",
vectorizer_config=[
Configure.NamedVectors.text2vec_aws(
name="title_vector",
region="sa-east-1",
source_properties=["title"],
service="bedrock",
model="amazon.titan-embed-text-v2:0",
)
],
generative_config=Configure.Generative.aws(
region="sa-east-1",
service="bedrock",
model="amazon.titan-text-express-v1"
)
)
collection.data.insert({"title": "This is a test"})
obj = collection.generate.fetch_objects(
include_vector=True,
limit=1,
single_prompt="Translate {title} to Portuguese"
).objects[0]
print(obj.generated)
print(len(obj.vector.get("title_vector")))
Let me know if this helps!