2222import com .alibaba .cloud .ai .dataagent .entity .AgentKnowledge ;
2323import com .alibaba .cloud .ai .dataagent .entity .BusinessKnowledge ;
2424import lombok .extern .slf4j .Slf4j ;
25+ import org .apache .commons .lang3 .StringUtils ;
2526import org .springframework .ai .document .Document ;
2627
2728import java .util .*;
@@ -56,7 +57,8 @@ public static List<Document> convertColumnsToDocuments(String agentId, List<Tabl
5657 */
5758 public static Document convertColumnToDocumentForAgent (String agentId , TableInfoBO tableInfoBO ,
5859 ColumnInfoBO columnInfoBO ) {
59- String text = Optional .ofNullable (columnInfoBO .getDescription ()).orElse (columnInfoBO .getName ());
60+ String text = StringUtils .isBlank (columnInfoBO .getDescription ()) ? columnInfoBO .getName ()
61+ : columnInfoBO .getDescription ();
6062 Map <String , Object > metadata = new HashMap <>();
6163 metadata .put ("name" , columnInfoBO .getName ());
6264 metadata .put ("tableName" , tableInfoBO .getName ());
@@ -80,7 +82,8 @@ public static Document convertColumnToDocumentForAgent(String agentId, TableInfo
8082 * @return Document object with table metadata
8183 */
8284 public static Document convertTableToDocumentForAgent (String agentId , TableInfoBO tableInfoBO ) {
83- String text = Optional .ofNullable (tableInfoBO .getDescription ()).orElse (tableInfoBO .getName ());
85+ String text = StringUtils .isBlank (tableInfoBO .getDescription ()) ? tableInfoBO .getName ()
86+ : tableInfoBO .getDescription ();
8487 Map <String , Object > metadata = new HashMap <>();
8588 metadata .put ("schema" , Optional .ofNullable (tableInfoBO .getSchema ()).orElse ("" ));
8689 metadata .put ("name" , tableInfoBO .getName ());
0 commit comments