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

fix: improve logic for detecting ChatFields #5667

Merged
merged 4 commits into from
Nov 6, 2024
Merged
Changes from 3 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
13 changes: 11 additions & 2 deletions argilla-frontend/v1/domain/entities/hub/Subset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { QuestionCreation } from "./QuestionCreation";
type Structure = {
name: string;
options?: string[];
role?: string;
content?: string;
Comment on lines +10 to +11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully understand this data structure but I think role and content are quite specific to be part of a general structure. Anyway, this is something to review with @damianpumar.

We can go on with this solution if everything is working well.

structure?: Structure[];
kindObject?: "Value" | "Image" | "ClassLabel" | "Sequence";
type?: "string" | MetadataTypes;
Expand All @@ -33,6 +35,7 @@ export class Subset {

for (const [name, value] of Object.entries<Feature>(datasetInfo.features)) {
if (Array.isArray(value)) {
const { role, content } = value[0];
this.structures.push({
name,
structure: value.map((v) => {
Expand All @@ -42,6 +45,8 @@ export class Subset {
name: key,
kindObject: value._type,
type: value.dtype,
role,
content,
Comment on lines +48 to +49
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're losing info by keeping only the first entry of value on this line (which is a dictionary of feature). This can introduce errors later. (Not for handling on this PR) cc @damianpumar

};
}),
});
Expand Down Expand Up @@ -134,8 +139,12 @@ export class Subset {
return "text";

if (structure.kindObject === "Image") return "image";

if (structure.structure?.length > 0) return "chat";
if (
structure.structure?.length > 0 &&
structure.structure[0].content &&
structure.structure[0].role
)
return "chat";
};

const field = FieldCreation.from(
Expand Down
Loading