Functions
hunch.output
Appends the given values to the output file. This function has a similar
signature to the built-in print.
Parameters:
*valuesobject : The values to be written to the output.sepOptional[str] : The separator between values. Defaults to a space.endOptional[str] : The string appended after the last value. Defaults to a newline.
hunch.input
Loads and returns the input JSON.
Returns:
- Input : The validated input data
hunch.compiled_prompt
Gets the entire compiled prompt.
Parameters:
instructionsbool : Whether to include the instructions of the code runner block. Defaults to false.titlesbool : Whether to include the titles of the blocks. Defaults to true.
- str : The compiled prompt
hunch.extract_url
Extracts the first URL from the upstream blocks.
Returns:
- str : The first URL found.
- Error : If no URL is found
hunch.extract_urls
Extracts all URLs from the upstream blocks.
Returns:
- list[str] : A list of all URLs found
hunch.block
Fetches an upstream block from the input.
Parameters:
titleOptional[str] : The title of the block to fetchititleOptional[str] : The case-insensitive title of the block to fetch
- Block : The block.
- Error : If the specified block is not found or if invalid arguments are provided.
Classes
class hunch.Input
Attributes
instructionsOptional[str] : The instructions on the code runner blockfilesOptional[list[File]] : The files contained in the instructionsblockslist[Block] : The blocks upstream of the code runner
class hunch.Block
Attributes
titlestr : The title of the block.outputstr : The output of the block or the content if the block is a content blockfilesOptional[list[File]] : The files contained in the block output
extract_url(self) -> str: Extracts the first URL from the block outputextract_urls(self) -> list[str]: Extracts all URLs from the block output
class hunch.File
Represents a file contained in a block.
Attributes
media_typeOptional[str] : The media type of the file (e.g. “application/pdf”, “image/jpeg”)urlstr : The URL to download the filepathOptional[Path]: The path to the file, if it has been downloaded
download(self, path: str | Path) -> None: Downloads the file to the given path and updates thepathattribute