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

Prompts in vectorstore? #16

Open
twardoch opened this issue Aug 4, 2024 · 1 comment
Open

Prompts in vectorstore? #16

twardoch opened this issue Aug 4, 2024 · 1 comment

Comments

@twardoch
Copy link

twardoch commented Aug 4, 2024

If I use a vectorstore for RAG already, and I have a lot of prompts/templates, it's compelling to treat the retrieval of the most suitable system prompt or prompt template like RAG.

Is this something that's easy to set up with prompt Poet?

@groeney
Copy link
Contributor

groeney commented Aug 7, 2024

A potential approach:

I use a vectorstore for RAG already... I have a lot of prompts/templates

As long as the prompts do not rely on interpolating runtime data--I would embed these prompts into your vectorstore.

Create a function that retrieves these prompts from vectorstore given any arbitrary runtime data-- ex. get_rag_prompt(user_query, ...).

Create a main prompt template that takes this function and any runtime data you need to pass to the function.

Within the template, invoke this function and bake the retval into (any number of) prompt parts.

main_template.yml.j2: where retval is a string-like object

{% set rag_prompt = get_rag_prompt(user_query) %}
{% if rag_prompt %}
- name: rag_prompt
  content: |
    {{ rag_prompt }}
{% endif %}

main_template.yml.j2: where retval is a list of string-like objects

{% set rag_prompt = get_rag_prompt(user_query) %}
{% for el in rag_prompt %}
- name: rag_prompt_{{ loop.index }}
  content: |
    {{ el }}
{% endif %}

Alternatively, you can embed the entire prompt poet template (yaml + jinja) and retrieve it but I doubt the semantics of the yaml and jinja will work out.

Open to other ideas!

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

2 participants