MadcowD / ell

A language model programming library.
http://docs.ell.so/
MIT License
5.2k stars 303 forks source link

Templates & file closurse? #252

Open MadcowD opened 1 month ago

MadcowD commented 1 month ago

This raises a new issue that we want to keep track of file dependencies as a part of lexical closures; right now we don't... Or we say f* it and we ad first class support for templating of some kind. Should think about this.

IF you did something like:

from os import path
from mako.template import Template

def load_prompt(prompt_file: str) -> Template:
    return Template(filename=path.join(f"prompts/{prompt_file}.txt"))

template = load_prompt("intentions/_default")

@ell.simple(model="llama-3.1-70b-versatile", temperature=0.1)
def intention(prompt: str):
    return template.render(prompt=prompt)

this would automatically version

MadcowD commented 1 month ago

234

skitsanos commented 1 month ago

Thank you for looking into it for me. (Original issue)

I just tested it yesterday. Damn, I like it :) Finally, I can have super complex logic in prompt template files.

MadcowD commented 1 month ago

Yay :)

Benoss commented 1 month ago

If we can add optional Jinja support that would be great as well

MadcowD commented 1 month ago

Once the API matures I will consider doing this in a separate package ell-jinja

On Sun, Sep 29, 2024 at 2:25 PM Benoit Chabord @.***> wrote:

If we can add optional Jinja support that would be great as well

— Reply to this email directly, view it on GitHub https://github.com/MadcowD/ell/issues/252#issuecomment-2381608745, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFPVL2YYCIBVOQ3OCVEEFLZZBV4XAVCNFSM6AAAAABO4I6KP6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBRGYYDQNZUGU . You are receiving this because you authored the thread.Message ID: @.***>

skitsanos commented 1 month ago

I also had a dilemma: to go with "usual" jinja or find something else... I went with mako, because every millisecond counts... (More details here)