Hi! I want to test the Cohere rerank module on my WCS database, and to do that I need to pass a Cohere API key with my requests.
I’m building my project using Flowise, and currently there’s no way to pass the key in a HTTP header through it. Is there a way I can set the API key as an environment variable for my database instead? How would I do that?
I tried setting up a sandbox cluster like this, adding my Cohere key:
import weaviate
client = weaviate.Client(
url=“endpoint”, # Replace with your endpoint
auth_client_secret=weaviate.AuthApiKey(api_key=“key”), # Replace with your Weaviate instance API key
additional_headers={
“X-Cohere-Api-Key”: “key”
}
)
if client.is_ready():
print(“Weaviate is ready!”)
else:
print(“Weaviate is not ready.”)
Then I set the class chema like this:
import weaviate
client = weaviate.Client(
url=“endpoint”, # Replace with your endpoint
auth_client_secret=weaviate.AuthApiKey(api_key=“key”), # Replace with your Weaviate instance API key
)
#Define the class schema
class_obj = {
“class”: “Reranktest”,
“vectorizer”: “none”,
“vectorIndexType”: “hnsw”,
“vectorIndexConfig”: {
“distance”: “dot”,
“efConstruction”: 254, # Higher value for accuracy, as per the documentation
“maxConnections”: 32, # Recommended starting value from the documentation
“ef”: 64 # Recommended starting value from the documentation
},
“moduleConfig”: {
“reranker-cohere”: {
“model”: “rerank-multilingual-v2.0”,
}
}
}
#Create the class
client.schema.create_class(class_obj)
print(“Class ‘Reranktest’ created successfully!”)
I can query the database as usual, but I’m getting the same similarity scores as when I used no reranker. Checking the debug log I don’t see the results having been reranked (not like the example responses over at Cohere). What am I missing?
Hi!
On top of defining the reranker module, you need to explicitly ask for a rerank in your query.
here we have a nice recipes, one of them on reranking:
Let me know if that helps
Thanks, that makes sense. I’m using Flowise to build my program, which is using Langchain JS. Unfortunately I don’t think the Langchain JS library has integrated other types of queries at the moment.