Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic prompts (e.g. using a vector store for memory) #15

Open
foogunlana opened this issue Aug 12, 2023 · 1 comment
Open

Dynamic prompts (e.g. using a vector store for memory) #15

foogunlana opened this issue Aug 12, 2023 · 1 comment

Comments

@foogunlana
Copy link

Hi @mistercrunch

Thanks for building this, it's sorely needed.

I noticed it's targeted at static prompts (You can write the prompt directly into the code).

This means it's useful for unit tests, but not e2e tests of prompts that load some of their text from a similarity search on a vector DB or other.

I think this could be easy to fix by adding another test case that relies on an external function or API call to call the LLM. Right now after skimming the code, my guess is that the PromptCase speaks directly to OpenAI and so there's no room for external calls to modify the prompt.

I think this would be a super useful feature as a lot of applications are being built with this architecture and have the same problem you're trying to solve as you build it for Preset. I'm happy to work on it as well if you think it's something you'd add to the repo.

class DynamicPromptCase:
      pass

# Later
from promtimize.prompts import DynamicPromptCase, 
from promptimize import evals

def enhance(prompt: str) -> str:
    context = "I like the following music the most: Organize by Asake (Afrobeats), Ride by Twenty-One Pilots (Band)."
    return f"Use the following context to answer my question\n{context}\n{prompt}"

simple_prompts = [
    DynamicPromptCase(
        "name my personal favourite band", enhance, lambda x: evals.all_words(x, ["Twenty-One Pilots"])
    ),
]
@foogunlana
Copy link
Author

A more general version of this could also let you swap out OpenAI entirely, so that the original PromptCase you have becomes a special case of the DynamicPromptCase with pre-defined values like OpenAI, and no enhancements, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant