Skip to content

Commit

Permalink
feat: expose raw parsing function
Browse files Browse the repository at this point in the history
  • Loading branch information
dkogut1996 committed Apr 26, 2024
1 parent 14fe924 commit 5d0af69
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,12 @@ type ParsedMetadata =
| { error: Error; metadata?: undefined }
| { error?: undefined; metadata: GGUFMetadata }

const parseMetadata = async (filePath: string): Promise<ParsedMetadata> => {
type RawMetadata =
| { error: Error }
| { error?: null; metadata: Record<string, any> }
export const parseRawMetadata = async (
filePath: string,
): Promise<RawMetadata> => {
const metadata = await new Promise<
{ error: Error } | { error?: null; metadata: Record<string, any> }
>((resolve) => {
Expand Down Expand Up @@ -554,6 +559,12 @@ const parseMetadata = async (filePath: string): Promise<ParsedMetadata> => {
})
})

return metadata
}

const parseMetadata = async (filePath: string): Promise<ParsedMetadata> => {
const metadata = await parseRawMetadata(filePath)

if (metadata.error) return { error: metadata.error }

const validationError = validateMetadata({
Expand Down

0 comments on commit 5d0af69

Please sign in to comment.