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

Adds context as first-class feature of Model. #61

Merged
merged 14 commits into from
May 8, 2024
Merged

Adds context as first-class feature of Model. #61

merged 14 commits into from
May 8, 2024

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.

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.

js/ai/src/prompt.ts Outdated Show resolved Hide resolved
js/dotprompt/src/prompt.ts Outdated Show resolved Hide resolved
@mbleigh mbleigh enabled auto-merge (squash) May 8, 2024 02:32
@mbleigh mbleigh merged commit 0106996 into main May 8, 2024
4 checks passed
@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants