Skip to content

Commit

Permalink
Add a widget with the chat (in addition of the side panel widget)
Browse files Browse the repository at this point in the history
  • Loading branch information
brichet committed Mar 5, 2024
1 parent ba2c3e5 commit 4adc59d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './model';
export * from './services';
export * from './widgets/chat-error';
export * from './widgets/chat-sidebar';
export * from './widgets/chat-widget';
43 changes: 43 additions & 0 deletions src/widgets/chat-widget.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { IThemeManager, ReactWidget } from '@jupyterlab/apputils';
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
import React from 'react';

import { Chat } from '../components/chat';
import { chatIcon } from '../icons';
import { IChatModel } from '../model';

export class ChatWidget extends ReactWidget {
constructor(options: ChatWidget.IOptions) {
super();

this.id = 'jupyter-chat::widget';
this.title.icon = chatIcon;
this.title.caption = 'Jupyter Chat'; // TODO: i18n

this._chatModel = options.chatModel;
this._themeManager = options.themeManager;
this._rmRegistry = options.rmRegistry;
}

render() {
return (
<Chat
chatModel={this._chatModel}
themeManager={this._themeManager}
rmRegistry={this._rmRegistry}
/>
);
}

private _chatModel: IChatModel;
private _themeManager: IThemeManager | null;
private _rmRegistry: IRenderMimeRegistry;
}

export namespace ChatWidget {
export interface IOptions {
chatModel: IChatModel;
themeManager: IThemeManager | null;
rmRegistry: IRenderMimeRegistry;
}
}

0 comments on commit 4adc59d

Please sign in to comment.