Jim_Le please help me your “Qdrant with Cohere ReRank“ give error “Not Found” I already check all qdrant setings It correct but it doesn’t work
const { QdrantClient } = require(‘
@qdrant/js-client-rest’);
const { CohereRerank } = require(“
@langchain/cohere”);
const { DynamicTool } = require(“
@langchain/core/tools”);
// 1. Tool Config
//const name = ‘bitcoin_whitepaper_tool’;
//const description = ‘Call this tool to get information and/or context from the Bitcoin Whitepaper’;
// 1. Tool Config
const name = ‘qdrant_document_retrieval_tool’;
const description = ‘Call this tool to get information and/or context from any document stored in Qdrant’;
// 2. Qdrant config
const client = new QdrantClient({
url: ‘https://localhost:6333’,
apiKey: ‘*****’
});
const collectionName = ‘RAG8.10_Sparse’;
const limit = 20;
// 3. Cohere config
const cohereRerank = new CohereRerank({
apiKey: ‘*****’, // Default
model: “rerank-multilingual-v3.0”, // Default
});
// 4. Inputs
const embeddings = await this.getInputConnectionData(‘ai_embedding’, 0);
const sparseVectorTool = await this.getInputConnectionData(‘ai_tool’, 0);
// 5. Tool definition
const vectorStoreTool = new DynamicTool({
name,
description,
func: async (input) => {
const denseVector = await embeddings.embedQuery(input);
const sparseVector = JSON.parse(await sparseVectorTool.invoke(input));
const response = await client.query(collectionName, {
prefetch: [
{
query: denseVector,
using: 'default',
limit: 100
},
{
query: sparseVector,
using: 'bm42',
limit: 100
}
],
query: { fusion: 'rrf' },
with_payload: true,
limit,
});
const docs = response.points.map(res => ({
pageContent: res.payload.content,
metadata: res.payload.metadata
}));
const rankings = await cohereRerank.rerank(docs, input);
rankings.forEach(rank => { docs[rank.index].score = rank.relevanceScore });
const rankedDocs = docs.toSorted((a,b) => b.score-a.score);
return JSON.stringify(rankedDocs);
}
});
return vectorStoreTool;