mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-13 21:17:08 +00:00
(improvement)(Chat) Put agent examples into ChatMemory automatically (#1249)
Co-authored-by: lxwcodemonkey
This commit is contained in:
@@ -7,6 +7,8 @@ import java.util.List;
|
||||
public interface ExemplarService {
|
||||
void storeExemplar(String collection, SqlExemplar exemplar);
|
||||
|
||||
void removeExemplar(String collection, SqlExemplar exemplar);
|
||||
|
||||
List<SqlExemplar> recallExemplars(String collection, String query, int num);
|
||||
|
||||
List<SqlExemplar> recallExemplars(String query, int num);
|
||||
|
||||
@@ -49,6 +49,14 @@ public class ExemplarServiceImpl implements ExemplarService, CommandLineRunner {
|
||||
embeddingService.addQuery(collection, Lists.newArrayList(segment));
|
||||
}
|
||||
|
||||
public void removeExemplar(String collection, SqlExemplar exemplar) {
|
||||
Metadata metadata = Metadata.from(JsonUtil.toMap(JsonUtil.toString(exemplar),
|
||||
String.class, Object.class));
|
||||
TextSegment segment = TextSegment.from(exemplar.getQuestion(), metadata);
|
||||
|
||||
embeddingService.deleteQuery(collection, Lists.newArrayList(segment));
|
||||
}
|
||||
|
||||
public List<SqlExemplar> recallExemplars(String query, int num) {
|
||||
String collection = embeddingConfig.getText2sqlCollectionName();
|
||||
return recallExemplars(collection, query, num);
|
||||
|
||||
Reference in New Issue
Block a user