11import { WeaviateClient } from "weaviate-client" ;
2- import { SearchModeResponse } from "./response/response.js" ;
2+ import {
3+ SearchExecutionOptions ,
4+ SearchModeResponse ,
5+ } from "./response/response.js" ;
36import { mapSearchOnlyResponse } from "./response/response-mapping.js" ;
47import { mapCollections , QueryAgentCollectionConfig } from "./collection.js" ;
58import { handleError } from "./response/error.js" ;
@@ -95,18 +98,19 @@ export class QueryAgentSearcher<T> {
9598 * in the same underlying searches being performed each time, allowing you to paginate
9699 * over a consistent results set.
97100 *
98- * @param options - Options for executing the search
99- * @param options.limit - The maximum number of results to return. Defaults to 20 if not specified.
100- * @param options.offset - The offset to start from. If not specified, retrieval begins from the first object.
101+ * @param [ options] - Options for executing the search
102+ * @param [ options.limit] - The maximum number of results to return. Defaults to 20 if not specified.
103+ * @param [ options.offset] - The offset to start from. If not specified, retrieval begins from the first object.
101104 * @returns A SearchModeResponse object containing the results, usage, and underlying searches performed.
102105 */
103- async run ( options : SearchExecutionOptions ) : Promise < SearchModeResponse < T > > {
106+ async run ( { limit = 20 , offset = 0 } : SearchExecutionOptions = { } ) : Promise <
107+ SearchModeResponse < T >
108+ > {
104109 if ( ! this . collections || this . collections . length === 0 ) {
105110 throw Error ( "No collections provided to the query agent." ) ;
106111 }
107112 const { requestHeaders, connectionHeaders } = await this . getHeaders ( ) ;
108113
109- const { limit = 20 , offset = 0 } = options ;
110114 const response = await fetch ( `${ this . agentsHost } /agent/search_only` , {
111115 method : "POST" ,
112116 headers : requestHeaders ,
@@ -128,16 +132,7 @@ export class QueryAgentSearcher<T> {
128132 }
129133 return {
130134 ...mappedResponse ,
131- next : async ( { limit : nextLimit = 20 , offset : nextOffset = 0 } = { } ) =>
132- this . run ( { limit : nextLimit , offset : nextOffset } ) ,
135+ next : async ( options : SearchExecutionOptions = { } ) => this . run ( options ) ,
133136 } ;
134137 }
135138}
136-
137- /** Options for the executing a prepared QueryAgent search. */
138- export type SearchExecutionOptions = {
139- /** The maximum number of results to return. */
140- limit ?: number ;
141- /** The offset of the results to return, for paginating through query result sets. */
142- offset ?: number ;
143- } ;
0 commit comments