Skip to content

Commit

Permalink
Display createdOn and type of the asset and embeddingType (#5766)
Browse files Browse the repository at this point in the history
  • Loading branch information
YohannParis authored Dec 5, 2024
1 parent 23195e5 commit bb368bd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
:asset="asset"
@click="emit('open-asset', data.id, asset.assetId, asset.assetType)"
/>
<p class="font-semibold">{{ capitalize(asset.embeddingType) }}</p>
<tera-show-more-text :text="asset.embeddingContent" :lines="3" />
</div>
</template>
Expand All @@ -78,6 +79,7 @@
<script setup lang="ts">
import { ref, watch } from 'vue';
import { v4 as uuidv4 } from 'uuid';
import { capitalize } from '@/utils/text';
import { formatDdMmmYyyy } from '@/utils/date';
import Column from 'primevue/column';
import DataTable, { DataTableExpandedRows } from 'primevue/datatable';
Expand Down
1 change: 1 addition & 0 deletions packages/client/hmi-client/src/types/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface ProjectSearchResultAsset {
assetId: string;
assetType: AssetType;
assetName: string;
createdOn: Date;
embeddingContent: string;
embeddingType: TerariumAssetEmbeddingType;
score: number;
Expand Down
7 changes: 6 additions & 1 deletion packages/client/hmi-client/src/utils/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ function highlightText(text: string, searchTerms: string): string {
return text.replace(search, (match) => emphasis(match));
}

function capitalize(string: string) {
return upperFirst(lowerCase(string));
}

/**
* Convert a pascal case string to a capital sentence, avoids acronyms.
* Most useful for converting enum of model framework to human-readable string:
Expand Down Expand Up @@ -52,5 +56,6 @@ export {
pascalCaseToCapitalSentence,
snakeToCapitalized,
snakeToCapitalSentence,
formatListWithConjunction
formatListWithConjunction,
capitalize
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.swagger.v3.oas.annotations.tags.Tags;
import jakarta.annotation.PostConstruct;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -1014,6 +1015,7 @@ public static class ProjectSearchResultAsset {
final UUID assetId;
final AssetType assetType;
final String assetName;
final Timestamp createdOn;
final String embeddingContent;
final TerariumAssetEmbeddingType embeddingType;
final Float score;
Expand Down Expand Up @@ -1129,6 +1131,7 @@ private ProjectSearchResultAsset createProjectSearchResultAsset(final ProjectSea
hit.getAssetId(),
hit.getAssetType(),
asset.getName(),
asset.getCreatedOn(),
embeddingContent,
hit.getEmbeddingType(),
hit.getScore()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,21 +362,15 @@ public boolean isPetrinet() {
}

private String getDescriptionAsReadableString() {
if (getDescription() == null) {
if (getMetadata().getDescription() == null) {
return null;
}

// decode from base64
final byte[] decodedBytes = Base64.getDecoder().decode(getDescription());
final String decodedString = new String(decodedBytes);

// remove image tags
final String regex = "<img\\b[^>]*>(.*?)<\\/img>|<img\\b[^>]*\\/>";
final Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
final Matcher matcher = pattern.matcher(decodedString);
final String result = matcher.replaceAll("");

return result;
final Matcher matcher = pattern.matcher(new String(getMetadata().getDescription()));
return matcher.replaceAll("");
}

@JsonIgnore
Expand Down

0 comments on commit bb368bd

Please sign in to comment.