1818import com .tinyengine .it .model .dto .AiToken ;
1919import com .tinyengine .it .model .dto .ChatRequest ;
2020
21+ import com .tinyengine .it .rag .entity .EmbeddingMatchDto ;
22+ import com .tinyengine .it .rag .entity .SearchRequest ;
23+ import com .tinyengine .it .rag .service .StorageService ;
2124import com .tinyengine .it .service .app .v1 .AiChatV1Service ;
2225import io .swagger .v3 .oas .annotations .Operation ;
2326import io .swagger .v3 .oas .annotations .Parameter ;
3740import org .springframework .web .bind .annotation .RestController ;
3841import org .springframework .web .servlet .mvc .method .annotation .StreamingResponseBody ;
3942
43+ import java .util .List ;
44+
4045/**
4146 * The type Ai chat controller.
4247 *
@@ -53,6 +58,9 @@ public class AiChatController {
5358 @ Autowired
5459 private AiChatV1Service aiChatV1Service ;
5560
61+ @ Autowired
62+ private StorageService vectorStorageService ;
63+
5664 /**
5765 * AI api
5866 *
@@ -151,4 +159,25 @@ public Result<AiToken> getToken(@RequestBody ChatRequest request) throws Excepti
151159 String token = aiChatV1Service .getToken (apiKey );
152160 return Result .success (new AiToken (token ));
153161 }
162+
163+ /**
164+ * search in collection
165+ *
166+ * @param searchDto the searchDto
167+ * @return result
168+ */
169+ @ Operation (summary = "在指定集合中搜索" , description = "在指定集合中搜索" ,
170+ parameters = {
171+ @ Parameter (name = "searchDto" , description = "搜索请求参数体" ),
172+ }, responses = {
173+ @ ApiResponse (responseCode = "200" , description = "返回信息" ,
174+ content = @ Content (mediaType = "application/json" , schema = @ Schema ())),
175+ @ ApiResponse (responseCode = "400" , description = "请求失败" )
176+ })
177+ @ SystemControllerLog (description = "AI search in collection" )
178+ @ PostMapping ("/ai/search" )
179+ public Result <List <EmbeddingMatchDto >> searchInCollection (@ RequestBody SearchRequest searchDto ) {
180+ List <EmbeddingMatchDto > results = vectorStorageService .search (searchDto );
181+ return Result .success (results );
182+ }
154183}
0 commit comments