Skip to content

Conversation

@mbleigh
Copy link
Collaborator

@mbleigh mbleigh commented May 7, 2024

This adds the ability to pass context (an array of DocumentData[]) to a model and adds default support for prompt augmentation if a model does not declare specific support for context. Usage:

const query = "What do cats like to eat?";
const docs = await retrieveStuff({query});

generate({
  prompt: `Answer this question: ${query}`,
  context: docs
});

This will augment the prompt to look something like this:

Answer this question: What do cats like to eat?

Use the following information to complete your task:

- [0]: Cats eat a variety of foods including dry kibble and wet foods that can be purchased at a pet store.
- [1]: Cats will hunt mice and birds for fun and for food.
@mbleigh mbleigh requested review from maxl0rd, pavelgj and ssbushi May 7, 2024 19:35
Copy link
Contributor

@maxl0rd maxl0rd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good. I like how dotprompt will let you position the context in the template.

Made one comment where I think you could thread it through to vanilla prompts too.

@mbleigh mbleigh enabled auto-merge (squash) May 8, 2024 02:32
@mbleigh mbleigh merged commit 0106996 into main May 8, 2024
@mbleigh mbleigh deleted the context branch May 8, 2024 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants