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

Expose templates for customisation in providers #581

Merged
merged 3 commits into from
Jan 25, 2024

Conversation

krassowski
Copy link
Member

@krassowski krassowski commented Jan 15, 2024

References

Code changes

Adds:

  • adds get_chat_prompt_template() to BaseProvider, allowing custom providers to override chat prompt template.
  • adds get_inline_completion_prompt_template() for completion template

@Marxlp
Copy link

Marxlp commented Jan 18, 2024

Nice work. Besides, I think it would be better to be able to configure prompt on the UI.

@krassowski krassowski changed the title Expose chat template for customisation in providers Expose templates for customisation in providers Jan 21, 2024
@krassowski
Copy link
Member Author

Besides, I think it would be better to be able to configure prompt on the UI.

I think this could be implemented in a follow up PR; the UI template should probably take precedence over provider-defined template.

@krassowski krassowski marked this pull request as ready for review January 21, 2024 14:20
@dlqqq
Copy link
Member

dlqqq commented Jan 23, 2024

Rebased this on latest main, reviewing & testing now.

Copy link
Member

@dlqqq dlqqq left a comment

Choose a reason for hiding this comment

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

Tested this locally and everything works. My only concern is regarding the method name; I would prefer get_completion_prompt_template() and drop the inline word. We should keep inline implicit if we don't support any other types of completion.

Also, I foresee difficulty with backporting this PR to 1.x as-is, since it also includes changes to the autocomplete work that is exclusive to 2.x. It might be easier to split the autocomplete-related changes into a separate PR and make this one smaller and "more backport-able". However, this is up to you, and I leave you the responsibility of backporting this PR. 👍

Finally, can you also consider a follow-up PR to remove the word inline from the completion handler classes? For example, DefaultInlineCompletionHandler => DefaultCompletionHandler. I would greatly prefer shorter and less redundant names.

@krassowski
Copy link
Member Author

We should keep inline implicit if we don't support any other types of completion.

Well, this is where we have different opinions - in #465 I included a detailed reasoning for using "inline completion" over just "completion" or other terms, let me quote it here:

  • why use "inline completion" vs "infill"? For consistency with other editors/frontend/LSP I went for "inline completions"; while this is a presentation detail, it does define what kind of information should be returned from models (a long multi-line suggestion; as compared to completions for tab-completions which would be also a kind of infill but needing many short, single-line completions)
  • why api/ai/completions/inline? to allow for creation of non-inline completion endpoints in the future

If you a specific term was used it would be easier in future to introduce other completion types. For example, some users prefer a AI-powered tab-completer which uses learned patterns to infer top k tokens to prioiritise (see tabnine, previously kite). As far as I know this is also the code name used in other IDEs so keeping it explicit makes the codebase easy to navigate for others.

Also, I foresee difficulty with backporting this PR to 1.x as-is, since it also includes changes to the autocomplete work that is exclusive to 2.x. It might be easier to split the autocomplete-related changes into a separate PR and make this one smaller and "more backport-able". However, this is up to you, and I leave you the responsibility of backporting this PR. 👍

Yes, I will take care of backport this - no worries.

@krassowski
Copy link
Member Author

Finally, can you also consider a follow-up PR to remove the word inline from the completion handler classes? For example, DefaultInlineCompletionHandler => DefaultCompletionHandler. I would greatly prefer shorter and less redundant names.

Sure if I have not convinced you on this one in the message above, I will open such a PR - just let me know :)

I would prefer get_completion_prompt_template() and drop the inline word.

Done in b235e0f.

@krassowski krassowski requested a review from dlqqq January 24, 2024 18:18
@krassowski
Copy link
Member Author

Rebased to pickup a single-word change in README 😆

Copy link
Member

@dlqqq dlqqq left a comment

Choose a reason for hiding this comment

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

@krassowski Thanks for addressing my feedback. I've approved this PR; you should have permission to merge & backport this PR yourself. If not, just ping me. 👍

Regarding "inline completion" v.s. "completion": I still prefer "completion" to be internally consistent; I think it's awkward how we only include the word "inline" when we have enough space for it. But I won't block on this, since you certainly know more about this topic than I do.

@krassowski krassowski merged commit 9907cc6 into jupyterlab:main Jan 25, 2024
8 checks passed
@krassowski
Copy link
Member Author

@meeseeksdev please backport to 1.x

Copy link

lumberbot-app bot commented Jan 25, 2024

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout 1.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 9907cc62b79738c4025c5949a576d8954613a67a
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #581: Expose templates for customisation in providers'
  1. Push to a named branch:
git push YOURFORK 1.x:auto-backport-of-pr-581-on-1.x
  1. Create a PR against branch 1.x, I would have named this PR:

"Backport PR #581 on branch 1.x (Expose templates for customisation in providers)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

dbelgrod pushed a commit to dbelgrod/jupyter-ai that referenced this pull request Jun 10, 2024
* Expose chat template for customisation in providers

* Enable completion template customization, including suffix

* Remove `inline` from "inline completion" as per review request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow prompt template customization for Jupyter AI chat.
3 participants