Skip to content

Commit

Permalink
Merge pull request instructlab#6 from ongstacy65/hotfix/contribute-ya…
Browse files Browse the repository at this point in the history
…ml-import-knowledge

[Hotfix] Types in the contribute yaml import knowledge
  • Loading branch information
artreimus authored Sep 22, 2024
2 parents 80888bb + 3ec76a5 commit bd895e0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/Import/KnowledgeYamlImport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { FormGroup } from '@patternfly/react-core/dist/dynamic/components/Form';
import { KnowledgeYamlData } from '@/types';
import { DropEvent } from '@patternfly/react-core/dist/esm/helpers/typeUtils';
import { SeedExample } from '../Contribute/Knowledge';
import { ValidatedOptions } from '@patternfly/react-core/dist/esm/helpers/constants';

interface KnowledgeYamlFileUploadProps {
onUploadSuccess: (data: SeedExample[]) => void;
Expand Down Expand Up @@ -34,11 +35,17 @@ const KnowledgeYamlFileUpload: React.FC<KnowledgeYamlFileUploadProps> = ({ onUpl
const yamlData = yaml.load(fileContent) as KnowledgeYamlData;
if (yamlData && yamlData.seed_examples) {
// Mapping the seed examples directly to the form format
const seedExamples = yamlData.seed_examples.map((example) => ({
const seedExamples: SeedExample[] = yamlData.seed_examples.map((example) => ({
immutable: true, // Assuming all seed examples are immutable
isExpanded: false, // Set default state of expansion
context: example.context,
isContextValid: ValidatedOptions.default, // Assuming context is valid by default
questionAndAnswers: example.questions_and_answers.map((qa) => ({
immutable: true, // Assuming questions/answers are immutable as well
question: qa.question,
answer: qa.answer
isQuestionValid: ValidatedOptions.default, // Default to valid
answer: qa.answer,
isAnswerValid: ValidatedOptions.default // Default to valid
}))
}));
onUploadSuccess(seedExamples); // Populate the form with seed examples
Expand Down

0 comments on commit bd895e0

Please sign in to comment.