@@ -48,7 +48,9 @@ public function getInputShapeEnumValues(): array {
4848 }
4949
5050 public function getInputShapeDefaults (): array {
51- return [];
51+ return [
52+ 'limit ' => 10 ,
53+ ];
5254 }
5355
5456 public function getOptionalInputShape (): array {
@@ -89,6 +91,11 @@ public function process(?string $userId, array $input, callable $reportProgress)
8991 throw new \RuntimeException ('Invalid input, expected "prompt" key with string value ' );
9092 }
9193
94+ if (!isset ($ input ['limit ' ]) || !is_numeric ($ input ['limit ' ])) {
95+ throw new \RuntimeException ('Invalid input, expected "limit" key with number value ' );
96+ }
97+ $ limit = (int )$ input ['limit ' ];
98+
9299 if (
93100 !isset ($ input ['scopeType ' ]) || !is_string ($ input ['scopeType ' ])
94101 || !isset ($ input ['scopeList ' ]) || !is_array ($ input ['scopeList ' ])
@@ -108,7 +115,13 @@ public function process(?string $userId, array $input, callable $reportProgress)
108115
109116 // unscoped query
110117 if ($ input ['scopeType ' ] === ScopeType::NONE ) {
111- $ response = $ this ->langRopeService ->docSearch ($ userId , $ input ['prompt ' ]);
118+ $ response = $ this ->langRopeService ->docSearch (
119+ $ userId ,
120+ $ input ['prompt ' ],
121+ null ,
122+ null ,
123+ $ limit ,
124+ );
112125 if (isset ($ response ['error ' ])) {
113126 throw new \RuntimeException ('No result in ContextChat response. ' . $ response ['error ' ]);
114127 }
@@ -139,6 +152,7 @@ public function process(?string $userId, array $input, callable $reportProgress)
139152 $ input ['prompt ' ],
140153 $ input ['scopeType ' ],
141154 $ processedScopes ,
155+ $ limit ,
142156 );
143157
144158 return $ this ->processResponse ($ userId , $ response );
@@ -154,7 +168,7 @@ public function process(?string $userId, array $input, callable $reportProgress)
154168 */
155169 private function processResponse (string $ userId , array $ response ): array {
156170 if (isset ($ response ['error ' ])) {
157- throw new \RuntimeException ('No result in ContextChat response : ' . $ response ['error ' ]);
171+ throw new \RuntimeException ('Error received in ContextChat document search request : ' . $ response ['error ' ]);
158172 }
159173 if (!array_is_list ($ response )) {
160174 throw new \RuntimeException ('Invalid response from ContextChat, expected a list: ' . json_encode ($ response ));
0 commit comments