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

Improve support for custom providers #713

Merged
merged 5 commits into from
Apr 4, 2024

Conversation

dlqqq
Copy link
Member

@dlqqq dlqqq commented Apr 3, 2024

Description

Custom providers may lack capabilities that are supported in other providers. Furthermore, some developers writing custom providers want to specify a persona, a custom name and avatar shown on agent replies in the chat UI.

This PR adds 3 new attributes to BaseProvider:

  1. manages_history (default: False): Whether this provider manages its own chat history upstream. This should be set to True if the provider service somehow persists its own chat history without the need for Jupyter AI to pass chat history as part of the prompt.

  2. unsupported_slash_commands (default: empty set): A set of slash commands unsupported by this provider. Unsupported slash commands are not shown in the help message and are not available for use while this provider is selected. For example, if a provider does not support RAG, this should be set to {/learn, /ask}.

  3. persona (default: None): A structure that contains a name and avatar that is shown on agent replies in the chat UI. When set to None (default), Jupyter AI will choose a persona, which currently defaults to JupyternautPersona. Otherwise, the persona set on this field takes precedence.

dlqqq added 3 commits April 3, 2024 08:04
adds 3 new provider class attributes:
1. `manages_history`
2. `unsupported_slash_commands`
3. `persona`
@dlqqq dlqqq added the enhancement New feature or request label Apr 3, 2024
Copy link
Member

@krassowski krassowski left a comment

Choose a reason for hiding this comment

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

Code looks good to me, just two small questions/suggestions.

Copy link
Collaborator

@3coins 3coins left a comment

Choose a reason for hiding this comment

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

@dlqqq
Works well! Some minor comments, looks good otherwise.

packages/jupyter-ai/jupyter_ai/models.py Outdated Show resolved Hide resolved
@dlqqq dlqqq force-pushed the better-custom-providers branch from 7d68955 to 568adcf Compare April 4, 2024 17:32
Copy link
Collaborator

@3coins 3coins left a comment

Choose a reason for hiding this comment

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

Looks good!
Thanks for accommodating the suggestions.

@dlqqq dlqqq merged commit 34051ba into jupyterlab:main Apr 4, 2024
8 checks passed
@dlqqq
Copy link
Member Author

dlqqq commented Apr 4, 2024

@meeseeksdev please backport to 1.x

Copy link

lumberbot-app bot commented Apr 4, 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 34051ba848ec0346ce77aa28fa9b3ce3ad4e776d
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #713: Improve support for custom providers'
  1. Push to a named branch:
git push YOURFORK 1.x:auto-backport-of-pr-713-on-1.x
  1. Create a PR against branch 1.x, I would have named this PR:

"Backport PR #713 on branch 1.x (Improve support for custom 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.

dlqqq added a commit that referenced this pull request Apr 4, 2024
…#715)

* improve support for custom providers

adds 3 new provider class attributes:
1. `manages_history`
2. `unsupported_slash_commands`
3. `persona`

* pre-commit

* add comment about jupyternaut icon in frontend

* remove 'avatar_path' from 'Persona', drop 'PersonaDescription'

* pre-commit
Marchlak pushed a commit to Marchlak/jupyter-ai that referenced this pull request Oct 28, 2024
* improve support for custom providers

adds 3 new provider class attributes:
1. `manages_history`
2. `unsupported_slash_commands`
3. `persona`

* pre-commit

* add comment about jupyternaut icon in frontend

* remove 'avatar_path' from 'Persona', drop 'PersonaDescription'

* pre-commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants