you can now pass in the filterExpression so that the messeger can change the default in settings
This commit is contained in:
parent
229cdee818
commit
0650f12bd5
@ -1,7 +1,3 @@
|
|||||||
const filter = {
|
|
||||||
filterExpression: CQA_RetrieverSettings.filterExpression,
|
|
||||||
};
|
|
||||||
|
|
||||||
const embedding = new langchain.openai.AzureOpenAIEmbeddings({
|
const embedding = new langchain.openai.AzureOpenAIEmbeddings({
|
||||||
azureOpenAIApiInstanceName:
|
azureOpenAIApiInstanceName:
|
||||||
CQA_RetrieverSettings.azure_openai_api.instance_name,
|
CQA_RetrieverSettings.azure_openai_api.instance_name,
|
||||||
@ -46,7 +42,12 @@ function getSourceId(document) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
async retrieve(query) {
|
async retrieve(query, filterExpression) {
|
||||||
|
console.log({ query: query, filterExpression:filterExpression})
|
||||||
|
const filter = {
|
||||||
|
filterExpression: filterExpression?? CQA_RetrieverSettings.filterExpression,
|
||||||
|
};
|
||||||
|
|
||||||
const resultDocuments = await store.similaritySearch(query, 20, filter);
|
const resultDocuments = await store.similaritySearch(query, 20, filter);
|
||||||
const sources = resultDocuments.map((doc) => ({
|
const sources = resultDocuments.map((doc) => ({
|
||||||
source_id: getSourceId(doc),
|
source_id: getSourceId(doc),
|
||||||
@ -71,4 +72,4 @@ return {
|
|||||||
|
|
||||||
return cqaSources;
|
return cqaSources;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -72,7 +72,7 @@ let exitState=0; // i.e. next(0) means something went wrong or we found 0 source
|
|||||||
(async () => {
|
(async () => {
|
||||||
console.log(`CQA Retrieval: ${conversationData.cqa_question}`)
|
console.log(`CQA Retrieval: ${conversationData.cqa_question}`)
|
||||||
conversationData.cqa_source = await CQA_Retriever().retrieve(conversationData.cqa_question);
|
conversationData.cqa_source = await CQA_Retriever().retrieve(conversationData.cqa_question);
|
||||||
console.log({ lengthOfSources: conversationData.cqa_source.instances[0].sources.length})
|
|
||||||
exitState = conversationData.cqa_source.instances[0].sources.length
|
exitState = conversationData.cqa_source.instances[0].sources.length
|
||||||
|
|
||||||
})()
|
})()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user