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 optional configurable message footer #942

Merged
merged 2 commits into from
Aug 12, 2024

Conversation

dlqqq
Copy link
Member

@dlqqq dlqqq commented Aug 7, 2024

Description

Demo

Screenshot 2024-08-07 at 3 31 41 PM

Testing instructions

To reproduce the above demo, add this test_plugin.tsx file under packages/jupyter-ai/src:

import React from 'react';
import {
  JupyterFrontEnd,
  JupyterFrontEndPlugin
} from '@jupyterlab/application';
import { IJaiMessageFooter, IJaiMessageFooterProps } from './tokens';

export const footerPlugin: JupyterFrontEndPlugin<IJaiMessageFooter> = {
  id: '@your-org/your-package:custom-footer',
  autoStart: true,
  requires: [],
  provides: IJaiMessageFooter,
  activate: (app: JupyterFrontEnd): IJaiMessageFooter => {
    return {
      component: MessageFooter
    };
  }
};

function MessageFooter(props: IJaiMessageFooterProps) {
  if (props.message.type !== 'agent' && props.message.type !== 'agent-stream') {
    return null;
  }

  return (
    <div>This is a test footer that renders under each agent message.</div>
  );
}

Then, in packages/jupyter-ai/src/index.ts, import this plugin & default-export it:

// index.ts

...

import { footerPlugin } from './test_plugin';

...

export default [plugin, statusItemPlugin, completionPlugin, footerPlugin];

@dlqqq dlqqq added the enhancement New feature or request label Aug 7, 2024
@JasonWeill JasonWeill enabled auto-merge (squash) August 12, 2024 20:49
@JasonWeill JasonWeill merged commit 512d642 into jupyterlab:main Aug 12, 2024
8 checks passed
@jtpio jtpio mentioned this pull request Aug 16, 2024
10 tasks
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.

Add frontend plugin to allow for a custom React component to be rendered under each message
2 participants