From 11f6e3883d2b2c1637516d870e0f872842ae17dc Mon Sep 17 00:00:00 2001 From: Abhishekfm Date: Wed, 25 Feb 2026 11:57:09 +0530 Subject: [PATCH] Required indicators and card description fixed --- .../[modelId]/components/Metadata/index.tsx | 45 +++- .../CollaborativesListingClient.tsx | 28 +- app/[locale]/(user)/components/Datasets.tsx | 5 +- app/[locale]/(user)/components/UseCases.tsx | 5 +- .../aimodels/edit/[id]/details/page.tsx | 26 +- .../aimodels/edit/[id]/versions/page.tsx | 254 ++++++++++-------- .../components/ChartGenVizPreview.tsx | 7 + .../charts/components/ChartEditor.tsx | 3 + .../charts/components/ChartForm.tsx | 4 + .../[id]/edit/components/AccessModelForm.tsx | 1 + .../[id]/edit/components/EditMetadata.tsx | 125 ++++++--- .../resources/components/EditResource.tsx | 80 +++--- .../edit/resources/views/components/bar.tsx | 2 + .../views/components/view-dialog.tsx | 2 + .../[id]/edit/resources/views/page.tsx | 1 + .../dataset/new/components/new-dataset.tsx | 5 +- 16 files changed, 368 insertions(+), 225 deletions(-) diff --git a/app/[locale]/(user)/aimodels/[modelId]/components/Metadata/index.tsx b/app/[locale]/(user)/aimodels/[modelId]/components/Metadata/index.tsx index 14306782..95db704b 100644 --- a/app/[locale]/(user)/aimodels/[modelId]/components/Metadata/index.tsx +++ b/app/[locale]/(user)/aimodels/[modelId]/components/Metadata/index.tsx @@ -66,8 +66,11 @@ export default function Metadata({ data }: MetadataProps) { }; // Get primary version info - const primaryVersion = data.versions?.find((v: any) => v.isLatest) || data.versions?.[0]; - const primaryProvider = primaryVersion?.providers?.find((p: any) => p.isPrimary) || primaryVersion?.providers?.[0]; + const primaryVersion = + data.versions?.find((v: any) => v.isLatest) || data.versions?.[0]; + const primaryProvider = + primaryVersion?.providers?.find((p: any) => p.isPrimary) || + primaryVersion?.providers?.[0]; const providerLabels: Record = { OPENAI: 'OpenAI', @@ -151,7 +154,10 @@ export default function Metadata({ data }: MetadataProps) { {/* Domain */} {data.domain && (
- + Domain @@ -163,11 +169,19 @@ export default function Metadata({ data }: MetadataProps) { {/* Source/Provider */} {primaryProvider && (
- + Source - - {providerLabels[primaryProvider.provider] || primaryProvider.provider} + + {providerLabels[primaryProvider.provider] || + primaryProvider.provider}
)} @@ -175,11 +189,15 @@ export default function Metadata({ data }: MetadataProps) { {/* License */} {data.metadata?.usageLicense && (
- + License - {licenseLabels[data.metadata.usageLicense] || data.metadata.usageLicense} + {licenseLabels[data.metadata.usageLicense] || + data.metadata.usageLicense}
)} @@ -187,7 +205,10 @@ export default function Metadata({ data }: MetadataProps) { {/* Sectors */} {data.sectors && data.sectors.length > 0 && (
- + Sector
@@ -209,7 +230,10 @@ export default function Metadata({ data }: MetadataProps) { {/* Geographies */} {data.geographies && data.geographies.length > 0 && (
- + Geography
@@ -226,7 +250,6 @@ export default function Metadata({ data }: MetadataProps) {
)} -
); diff --git a/app/[locale]/(user)/collaboratives/CollaborativesListingClient.tsx b/app/[locale]/(user)/collaboratives/CollaborativesListingClient.tsx index 504e5ef4..f73100a2 100644 --- a/app/[locale]/(user)/collaboratives/CollaborativesListingClient.tsx +++ b/app/[locale]/(user)/collaboratives/CollaborativesListingClient.tsx @@ -14,31 +14,7 @@ import { Icons } from '@/components/icons'; import JsonLd from '@/components/JsonLd'; import { Loading } from '@/components/loading'; import Styles from '../datasets/dataset.module.scss'; - -// Helper function to strip markdown and HTML tags for card preview -const stripMarkdown = (markdown: string): string => { - if (!markdown) return ''; - return markdown - .replace(/```[\s\S]*?```/g, '') - .replace(/`([^`]+)`/g, '$1') - .replace(/!\[([^\]]*)\]\([^)]+\)/g, '$1') - .replace(/\[([^\]]+)\]\([^)]+\)/g, '$1') - .replace(/^#{1,6}\s+/gm, '') - .replace(/\*\*([^*]+)\*\*/g, '$1') - .replace(/__([^_]+)__/g, '$1') - .replace(/\*([^*]+)\*/g, '$1') - .replace(/_([^_]+)_/g, '$1') - .replace(/~~([^~]+)~~/g, '$1') - .replace(/^\s*>\s+/gm, '') - .replace(/^(-{3,}|_{3,}|\*{3,})$/gm, '') - .replace(/^\s*[-*+]\s+/gm, '') - .replace(/^\s*\d+\.\s+/gm, '') - .replace(/<[^>]*>/g, '') - .replace(/\n\s*\n/g, '\n') - .replace(/\n/g, ' ') - .replace(/\s+/g, ' ') - .trim(); -}; +import { stripMarkdown } from '../search/components/UnifiedListingComponent'; const PublishedCollaboratives = graphql(` query PublishedCollaboratives { @@ -367,7 +343,7 @@ const CollaborativesListingClient = () => { label: 'Published by', }, ]} - description={stripMarkdown(collaborative.summary || '')} + description={`rest ${stripMarkdown(collaborative.summary || '')}`} /> ) )} diff --git a/app/[locale]/(user)/components/Datasets.tsx b/app/[locale]/(user)/components/Datasets.tsx index fb7860d0..07854011 100644 --- a/app/[locale]/(user)/components/Datasets.tsx +++ b/app/[locale]/(user)/components/Datasets.tsx @@ -17,6 +17,7 @@ import { import { cn } from '@/lib/utils'; import { Icons } from '@/components/icons'; import { DatasetListingSkeleton } from '@/components/loading'; +import { stripMarkdown } from '../search/components/UnifiedListingComponent'; import Styles from './datasets.module.scss'; interface Bucket { @@ -65,7 +66,7 @@ const Datasets = () => {
diff --git a/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/components/AccessModelForm.tsx b/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/components/AccessModelForm.tsx index 74e3f296..dbff118a 100644 --- a/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/components/AccessModelForm.tsx +++ b/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/components/AccessModelForm.tsx @@ -459,6 +459,7 @@ const AccessModelForm: React.FC = ({ label="Access Type Name" name="name" required + requiredIndicator={true} helpText="To know about best practices for naming Resources go to our User Guide" />
diff --git a/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/components/EditMetadata.tsx b/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/components/EditMetadata.tsx index 80820b11..e84660df 100644 --- a/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/components/EditMetadata.tsx +++ b/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/components/EditMetadata.tsx @@ -1,5 +1,7 @@ 'use client'; +import { useEffect, useState } from 'react'; +import { useParams } from 'next/navigation'; import { graphql } from '@/gql'; import { TypeDataset, @@ -9,7 +11,6 @@ import { UpdateMetadataInput, } from '@/gql/generated/graphql'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; -import { useParams } from 'next/navigation'; import { Checkbox, Combobox, @@ -18,12 +19,11 @@ import { Input, Select, Text, - toast + toast, } from 'opub-ui'; -import { useEffect, useState } from 'react'; -import { RichTextEditor } from '@/components/RichTextEditor'; import { GraphQL } from '@/lib/api'; +import { RichTextEditor } from '@/components/RichTextEditor'; import DatasetLoading from '../../../components/loading-dataset'; import { useDatasetEditStatus } from '../context'; @@ -389,7 +389,8 @@ export function EditMetadata({ id }: { id: string }) { 'Error: ' + (res.updatePromptMetadata?.errors?.fieldErrors ? res.updatePromptMetadata?.errors?.fieldErrors[0]?.messages[0] - : res.updatePromptMetadata?.errors?.nonFieldErrors?.[0] || 'Unknown error') + : res.updatePromptMetadata?.errors?.nonFieldErrors?.[0] || + 'Unknown error') ); } }, @@ -403,7 +404,7 @@ export function EditMetadata({ id }: { id: string }) { const savePromptMetadata = (updates: Partial) => { const newState = { ...promptMetadataState, ...updates }; setPromptMetadataState(newState); - + updatePromptMetadataMutation.mutate({ updateInput: { dataset: params.id, @@ -526,7 +527,9 @@ export function EditMetadata({ id }: { id: string }) { }; const [formData, setFormData] = useState( - defaultValuesPrepFn(getDatasetMetadata?.data?.datasets?.[0] || {} as TypeDataset) + defaultValuesPrepFn( + getDatasetMetadata?.data?.datasets?.[0] || ({} as TypeDataset) + ) ); const [previousFormData, setPreviousFormData] = useState(formData); @@ -621,7 +624,9 @@ export function EditMetadata({ id }: { id: string }) { sectors: changedFields.sectors.map((item: any) => item.value), }), ...(changedFields.geographies && { - geographies: changedFields.geographies.map((item: any) => parseInt(item.value, 10)), + geographies: changedFields.geographies.map((item: any) => + parseInt(item.value, 10) + ), }), }, }); @@ -850,13 +855,15 @@ export function EditMetadata({ id }: { id: string }) { {/* Prompt-specific metadata fields - only shown for PROMPT type datasets */} - {getDatasetMetadata.data?.datasets?.[0]?.datasetType === 'PROMPT' && ( -
+ {getDatasetMetadata.data?.datasets?.[0]?.datasetType === + 'PROMPT' && ( +
Prompt Dataset Metadata - Additional metadata specific to prompt datasets for AI/ML use cases. + Additional metadata specific to prompt datasets for AI/ML + use cases.
({ - label: enumValue.name.replace(/_/g, ' ').replace(/\b\w/g, (c: string) => c.toUpperCase()), + (enumValue: { + name: string; + description?: string; + }) => ({ + label: enumValue.name + .replace(/_/g, ' ') + .replace(/\b\w/g, (c: string) => c.toUpperCase()), value: enumValue.name, }) ) || [] } selectedValue={ promptMetadataState.taskType - ? [{ - label: promptMetadataState.taskType.replace(/_/g, ' ').replace(/\b\w/g, (c: string) => c.toUpperCase()), - value: promptMetadataState.taskType - }] + ? [ + { + label: promptMetadataState.taskType + .replace(/_/g, ' ') + .replace(/\b\w/g, (c: string) => + c.toUpperCase() + ), + value: promptMetadataState.taskType, + }, + ] : [] } onChange={(value) => { - const selectedValue = Array.isArray(value) ? value[0]?.value : value; + const selectedValue = Array.isArray(value) + ? value[0]?.value + : value; savePromptMetadata({ taskType: selectedValue }); }} /> @@ -890,22 +910,35 @@ export function EditMetadata({ id }: { id: string }) { displaySelected list={ getPromptDomainEnum.data?.__type?.enumValues?.map( - (enumValue: { name: string; description?: string }) => ({ - label: enumValue.name.replace(/_/g, ' ').replace(/\b\w/g, (c: string) => c.toUpperCase()), + (enumValue: { + name: string; + description?: string; + }) => ({ + label: enumValue.name + .replace(/_/g, ' ') + .replace(/\b\w/g, (c: string) => c.toUpperCase()), value: enumValue.name, }) ) || [] } selectedValue={ promptMetadataState.domain - ? [{ - label: promptMetadataState.domain.replace(/_/g, ' ').replace(/\b\w/g, (c: string) => c.toUpperCase()), - value: promptMetadataState.domain - }] + ? [ + { + label: promptMetadataState.domain + .replace(/_/g, ' ') + .replace(/\b\w/g, (c: string) => + c.toUpperCase() + ), + value: promptMetadataState.domain, + }, + ] : [] } onChange={(value) => { - const selectedValue = Array.isArray(value) ? value[0]?.value : value; + const selectedValue = Array.isArray(value) + ? value[0]?.value + : value; savePromptMetadata({ domain: selectedValue }); }} /> @@ -916,22 +949,31 @@ export function EditMetadata({ id }: { id: string }) { creatable list={ getTargetLanguageEnum.data?.__type?.enumValues?.map( - (enumValue: { name: string; description?: string }) => ({ - label: enumValue.name.replace(/_/g, ' ').replace(/\b\w/g, (c: string) => c.toUpperCase()), + (enumValue: { + name: string; + description?: string; + }) => ({ + label: enumValue.name + .replace(/_/g, ' ') + .replace(/\b\w/g, (c: string) => c.toUpperCase()), value: enumValue.name, }) ) || [] } selectedValue={ promptMetadataState.targetLanguages?.map( - (lang: string) => ({ - label: lang.replace(/_/g, ' ').replace(/\b\w/g, (c: string) => c.toUpperCase()), - value: lang + (lang: string) => ({ + label: lang + .replace(/_/g, ' ') + .replace(/\b\w/g, (c: string) => c.toUpperCase()), + value: lang, }) ) || [] } onChange={(value) => { - const languages = Array.isArray(value) ? value.map((v: any) => v.value) : []; + const languages = Array.isArray(value) + ? value.map((v: any) => v.value) + : []; savePromptMetadata({ targetLanguages: languages }); }} /> @@ -942,22 +984,31 @@ export function EditMetadata({ id }: { id: string }) { creatable list={ getTargetModelTypeEnum.data?.__type?.enumValues?.map( - (enumValue: { name: string; description?: string }) => ({ - label: enumValue.name.replace(/_/g, ' ').replace(/\b\w/g, (c: string) => c.toUpperCase()), + (enumValue: { + name: string; + description?: string; + }) => ({ + label: enumValue.name + .replace(/_/g, ' ') + .replace(/\b\w/g, (c: string) => c.toUpperCase()), value: enumValue.name, }) ) || [] } selectedValue={ promptMetadataState.targetModelTypes?.map( - (model: string) => ({ - label: model.replace(/_/g, ' ').replace(/\b\w/g, (c: string) => c.toUpperCase()), - value: model + (model: string) => ({ + label: model + .replace(/_/g, ' ') + .replace(/\b\w/g, (c: string) => c.toUpperCase()), + value: model, }) ) || [] } onChange={(value) => { - const models = Array.isArray(value) ? value.map((v: any) => v.value) : []; + const models = Array.isArray(value) + ? value.map((v: any) => v.value) + : []; savePromptMetadata({ targetModelTypes: models }); }} /> diff --git a/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/resources/components/EditResource.tsx b/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/resources/components/EditResource.tsx index 2764b0c4..dcd1070f 100644 --- a/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/resources/components/EditResource.tsx +++ b/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/resources/components/EditResource.tsx @@ -1,34 +1,34 @@ +import React, { useEffect, useState } from 'react'; +import { useParams } from 'next/navigation'; import { graphql } from '@/gql'; import { - CreateFileResourceInput, - SchemaUpdateInput, - UpdateFileResourceInput, + CreateFileResourceInput, + SchemaUpdateInput, + UpdateFileResourceInput, } from '@/gql/generated/graphql'; import { useMutation, useQuery } from '@tanstack/react-query'; -import { useParams } from 'next/navigation'; import { parseAsString, useQueryState } from 'nuqs'; import { - Button, - Checkbox, - Combobox, - Divider, - DropZone, - Text, - TextField, - toast, + Button, + Checkbox, + Combobox, + Divider, + DropZone, + Text, + TextField, + toast, } from 'opub-ui'; -import React, { useEffect, useState } from 'react'; -import { Loading } from '@/components/loading'; import { GraphQL } from '@/lib/api'; +import { Loading } from '@/components/loading'; import PdfPreview from '../../../../../../../../(user)/components/PdfPreview'; import { useDatasetEditStatus } from '../../context'; import { TListItem } from '../page-layout'; import PreviewData from './PreviewData'; import { - createResourceFilesDoc, - updateResourceDoc, - updateSchema, + createResourceFilesDoc, + updateResourceDoc, + updateSchema, } from './query'; import ResourceHeader from './ResourceHeader'; import { ResourceSchema } from './ResourceSchema'; @@ -146,7 +146,8 @@ const PROMPT_FORMAT_TEMPLATES: Record< { description: string; template: string } > = { INSTRUCTION: { - description: 'Single instruction with expected output format. Each row is one prompt.', + description: + 'Single instruction with expected output format. Each row is one prompt.', template: `instruction,input,output "Translate the following English text to Hindi","Hello, how are you?","नमस्ते, आप कैसे हैं?" "Summarize the following text","Artificial Intelligence is transforming industries worldwide.","AI is changing industries globally." @@ -161,35 +162,40 @@ const PROMPT_FORMAT_TEMPLATES: Record< "You are a language expert.","How do you say hello in Spanish?","In Spanish, hello is 'Hola'."`, }, COMPLETION: { - description: 'Text completion format with prompt and completion pairs. Each row is one prompt-completion pair.', + description: + 'Text completion format with prompt and completion pairs. Each row is one prompt-completion pair.', template: `prompt,completion "The capital of France is"," Paris, which is known for the Eiffel Tower." "The largest ocean on Earth is"," the Pacific Ocean, covering more than 60 million square miles." "The chemical symbol for gold is"," Au, derived from the Latin word aurum."`, }, FEW_SHOT: { - description: 'Examples followed by the actual task. Each row contains example pairs and the task.', + description: + 'Examples followed by the actual task. Each row contains example pairs and the task.', template: `example_input_1,example_output_1,example_input_2,example_output_2,task_input,task_output "happy","sad","big","small","hot","cold" "up","down","left","right","forward","backward" "day","night","sun","moon","light","dark"`, }, CHAIN_OF_THOUGHT: { - description: 'Step-by-step reasoning format. Each row shows question, reasoning steps, and answer.', + description: + 'Step-by-step reasoning format. Each row shows question, reasoning steps, and answer.', template: `question,reasoning,answer "If John has 5 apples and gives 2 to Mary, how many does he have?","John starts with 5 apples. He gives away 2 apples. 5 - 2 = 3.","John has 3 apples." "A train travels 60 km in 1 hour. How far does it travel in 3 hours?","Speed is 60 km/hour. Distance = Speed × Time. Distance = 60 × 3 = 180 km.","The train travels 180 km." "If 3 pencils cost $6, how much does 1 pencil cost?","Total cost is $6 for 3 pencils. Cost per pencil = $6 ÷ 3 = $2.","One pencil costs $2."`, }, ZERO_SHOT: { - description: 'Direct task without examples. Each row is one task-input-output triplet.', + description: + 'Direct task without examples. Each row is one task-input-output triplet.', template: `task,input,output "Classify the sentiment of the following text","I love this product! It works great.","positive" "Identify the language","Bonjour, comment allez-vous?","French" "Extract the main topic","The article discusses climate change and its impact on agriculture.","climate change"`, }, OTHER: { - description: 'Custom format - define your own columns. Each row is one prompt.', + description: + 'Custom format - define your own columns. Each row is one prompt.', template: `custom_field_1,custom_field_2,custom_field_3 "value1","value2","value3" "value4","value5","value6" @@ -572,7 +578,11 @@ export const EditResource = ({ ? 'loading' : 'success' ); // update based on mutation state - }, [setStatus, updateResourceMutation.isLoading, updateSchemaMutation.isLoading]); + }, [ + setStatus, + updateResourceMutation.isLoading, + updateSchemaMutation.isLoading, + ]); const resourceFormat = resourceDetailsQuery.data?.resourceById.fileDetails.format?.toLowerCase(); @@ -609,6 +619,7 @@ export const EditResource = ({ } name="a" required + requiredIndicator={true} />
{isPromptDataset ? ( @@ -630,16 +641,13 @@ export const EditResource = ({ }) ) || [] } - selectedValue={ - promptFormat - ? promptFormat - : '' - } + selectedValue={promptFormat ? promptFormat : ''} onChange={(value: any) => { // Handle both array and string values let selectedValue: string | undefined; if (Array.isArray(value)) { - selectedValue = value.length > 0 ? value[0]?.value : undefined; + selectedValue = + value.length > 0 ? value[0]?.value : undefined; } else { selectedValue = value || undefined; } @@ -685,8 +693,8 @@ export const EditResource = ({ {PROMPT_FORMAT_TEMPLATES[promptFormat].description} -
- +
+
{PROMPT_FORMAT_TEMPLATES[promptFormat].template @@ -695,7 +703,7 @@ export const EditResource = ({ .map((header, idx) => ( @@ -707,11 +715,13 @@ export const EditResource = ({ .split('\n') .slice(1) .map((row, rowIdx) => { - const cells = row.match(/(".*?"|[^,]+)(?=\s*,|\s*$)/g) || []; + const cells = + row.match(/(".*?"|[^,]+)(?=\s*,|\s*$)/g) || + []; return ( {cells.map((cell, cellIdx) => (
{header.trim()}
{ label="X Axis" selectedValue={xAxis} required + requiredIndicator={true} error="X Axis is required" onChange={(e) => { setXAxis(e); @@ -96,6 +97,7 @@ export const Bar = ({ type, ...props }: { type: string; [x: string]: any }) => { label="Y Axis" selectedValue={yAxis} required + requiredIndicator={true} error="Y Axis is required" onChange={(e) => { setYAxis(e); diff --git a/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/resources/views/components/view-dialog.tsx b/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/resources/views/components/view-dialog.tsx index 9f40670b..18e27c39 100644 --- a/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/resources/views/components/view-dialog.tsx +++ b/app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/resources/views/components/view-dialog.tsx @@ -109,6 +109,7 @@ export const ViewDialog = ({ value={viewName} onChange={setViewName} required + requiredIndicator={true} error="View name is required" />