jkomoros / prompt-garden

A framework for gardening LLM prompts
Apache License 2.0
9 stars 0 forks source link

Make template `json` extraction work #59

Open jkomoros opened 1 year ago

jkomoros commented 1 year ago

The json modifier for template extraction currently doens't work for JSON that has sub-objects

For example, changing the test json modifier full text multi-line to :

{
    "a": 1,
    "b":[
        2,
        3
    ],
    "c": {
        "a": true
    }
}

Fails, because of the sub-object. The normal way of doing this is to use recursive match patterns, which arent' supported in javascript. This makes the whole "extract JSON" using the current Regex-based template matching pipeline not viable...

The only fix I see is to change the whole template extraction pipeline to not rely on regexes (or rather, to have a higher-level construct that might use regexes for pieces, but for json extraction doesn't)

Originally captured in #17.