@@ -18,7 +18,7 @@ class VectaraRM(dspy.Retrieve):
1818 """
1919 A retrieval module that uses Vectara to return the top passages for a given query.
2020
21- Assumes that a Vectara corpus has been created and populated with the following payload:
21+ Assumes that a Vectara corpora have been created and populated with the following payload:
2222 - document: The text of the passage
2323
2424 Args:
@@ -67,17 +67,27 @@ def __init__(
6767 def _vectara_query (
6868 self ,
6969 query : str ,
70- limit : int = 3 ,
70+ limit : int = 5 ,
7171 ) -> List [str ]:
7272 """Query Vectara index to get for top k matching passages.
7373 Args:
7474 query: query string
7575 """
76- corpus_key = {
77- "customerId" : self ._vectara_customer_id ,
78- "corpusId" : self ._vectara_corpus_id ,
79- "lexicalInterpolationConfig" : {"lambda" : 0.025 },
80- }
76+ # If multiple corpus ids are provided (comma-separated), create a list of corpus keys
77+ if ',' in self ._vectara_corpus_id :
78+ corpus_key = [
79+ {
80+ "customerId" : self ._vectara_customer_id ,
81+ "corpusId" : corpus_id ,
82+ "lexicalInterpolationConfig" : {"lambda" : 0.025 },
83+ } for corpus_id in self ._vectara_corpus_id .split (',' )
84+ ]
85+ else :
86+ corpus_key = [{
87+ "customerId" : self ._vectara_customer_id ,
88+ "corpusId" : self ._vectara_corpus_id ,
89+ "lexicalInterpolationConfig" : {"lambda" : 0.025 },
90+ }]
8191
8292 data = {
8393 "query" : [
@@ -91,7 +101,7 @@ def _vectara_query(
91101 "startTag" : START_SNIPPET ,
92102 "endTag" : END_SNIPPET ,
93103 },
94- "corpusKey" : [ corpus_key ] ,
104+ "corpusKey" : corpus_key ,
95105 },
96106 ],
97107 }
0 commit comments