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

Add ability to shrink conversation based on cost/budget/importance #228

Merged
merged 4 commits into from
Aug 3, 2023

Conversation

petersalas
Copy link
Contributor

This adds a new affordance to renderToConversation where a cost function (i.e. a function that measures/estimates how many tokens any given message consumes) and a budget can be provided.

If the conversation contains <Shrinkable> components, those portions of the conversation will be replaced until the total conversation cost is less than the provided budget.

<Shrinkable> has two props of note:

  • importance -- the shrinking algorithm replaces the least important sections first
  • replacement -- the AI.Node with which the section will be replaced

A current limitation is that the <Shrinkable> components need to wrap the message components entirely and have no effect when used within a message component.

Additionally:

  • Change the tokenizer dependency to js-tiktoken for compatibility with the OpenAI chat models
  • Fix a bug in NLRouter where the unmatched route was using the wrong index
  • Change withContext so as not to replace an existing binding. (This ensures that components can be memoized multiple times without being re-rendered.)

@vercel
Copy link

vercel bot commented Aug 2, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ai-jsx-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 3, 2023 5:11pm
ai-jsx-nextjs-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 3, 2023 5:11pm
ai-jsx-tutorial-nextjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 3, 2023 5:11pm

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.

2 participants