Skip to content

Commit

Permalink
Refactor entry parsing in Knowledge Base bulk import to declare entri…
Browse files Browse the repository at this point in the history
…es with proper type
  • Loading branch information
arturoliduena committed Jan 7, 2025
1 parent 2456787 commit bd7b560
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ export function KnowledgeBaseBulkImportFlyout({ onClose }: { onClose: () => void
};

const handleSubmitNewEntryClick = async () => {
let entries: Array<Omit<KnowledgeBaseEntry, '@timestamp' | 'title'> & { title: string }> = [];
const text = await files[0].text();

const elements = text.split('\n').filter(Boolean);

try {
entries = elements.map((el) => JSON.parse(el));
const entries: Array<Omit<KnowledgeBaseEntry, '@timestamp' | 'title'> & { title: string }> =
elements.map((el) => JSON.parse(el));
await mutateAsync({ entries });
} catch (_) {
toasts.addError(
Expand Down

0 comments on commit bd7b560

Please sign in to comment.