UNPKG

@promptbook/remote-server

Version:

Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action

22 lines (21 loc) 1.18 kB
import type { string_json, string_markdown } from '../../types/string_markdown'; import type { really_unknown } from '../../utils/organization/really_unknown'; /** * Extracts extracts exactly one valid JSON code block * * - When given string is a valid JSON as it is, it just returns it * - When there is no JSON code block the function throws a `ParseError` * - When there are multiple JSON code blocks the function throws a `ParseError` * * Note: It is not important if marked as ```json BUT if it is VALID JSON * Note: There are multiple similar function: * - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing * - `extractJsonBlock` extracts exactly one valid JSON code block * - `extractOneBlockFromMarkdown` extracts exactly one code block with language of the code block * - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block * * @throws {ParseError} if there is no valid JSON block in the markdown * * @public exported from `@promptbook/markdown-utils` */ export declare function extractJsonBlock(markdown: string_markdown): string_json<really_unknown>;