How to Extract Text Blocks for Insertion into Prompts

I’ve created a Python command-line tool that reads software code-bases and extracts named “Blocks of Code” that can then be inserted automatically into Prompt Templates. It allows you to put stuff like this in your code:

// block.begin My_Named_Block
... a bunch of java code here
// block.end

And then you can use ${My_Named_Block} in a prompt, to inject the code. It will of course work in ordinary text files too, not necessarily just software projects.

I’m wondering if I’ve re-invented some syntax I’m unaware of that already does this? That is, any existing syntax to name/extract code blocks. Any comments or feed back is appreciated.

Here’s the Langchain-based MIT License Open Source project that makes calls to OpenAI for it’s AI Service:

Quanta OpenAI Agent (Python Project)

1 Like