Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display createdOn and type of the asset and embeddingType #5766

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
}

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()));
Dismissed Show dismissed Hide dismissed
return matcher.replaceAll("");
}

@JsonIgnore
Expand Down