@jupyter-ai/jupyternaut 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { INotebookShell } from '@jupyter-notebook/application';
|
|
2
2
|
import { IThemeManager, MainAreaWidget, ICommandPalette } from '@jupyterlab/apputils';
|
|
3
|
-
import { IMessageFooterRegistry } from '@jupyter/chat';
|
|
4
3
|
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
5
4
|
import { SingletonLayout, Widget } from '@lumino/widgets';
|
|
6
|
-
import { StopButton } from './components/message-footer/stop-button';
|
|
7
5
|
//import { completionPlugin } from './completions';
|
|
8
6
|
import { buildErrorWidget } from './widgets/chat-error';
|
|
9
7
|
import { buildAiSettings } from './widgets/settings-widget';
|
|
@@ -95,22 +93,10 @@ const jupyternautSettingsPlugin = {
|
|
|
95
93
|
}
|
|
96
94
|
}
|
|
97
95
|
};
|
|
98
|
-
const stopButtonPlugin = {
|
|
99
|
-
id: '@jupyter-ai/jupyternaut:stop-button',
|
|
100
|
-
autoStart: true,
|
|
101
|
-
requires: [IMessageFooterRegistry],
|
|
102
|
-
activate: (app, registry) => {
|
|
103
|
-
registry.addSection({
|
|
104
|
-
component: StopButton,
|
|
105
|
-
position: 'center'
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
96
|
export default [
|
|
110
97
|
plugin,
|
|
111
98
|
jupyternautSettingsPlugin,
|
|
112
99
|
// webComponentsPlugin,
|
|
113
|
-
stopButtonPlugin,
|
|
114
100
|
// completionPlugin,
|
|
115
101
|
statusItemPlugin
|
|
116
102
|
];
|
package/package.json
CHANGED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { TooltippedButton } from '@jupyter/chat';
|
|
2
|
-
import StopIcon from '@mui/icons-material/Stop';
|
|
3
|
-
import React, { useEffect, useState } from 'react';
|
|
4
|
-
import { requestAPI } from '../../handler';
|
|
5
|
-
/**
|
|
6
|
-
* The stop button.
|
|
7
|
-
*/
|
|
8
|
-
export function StopButton(props) {
|
|
9
|
-
const { message, model } = props;
|
|
10
|
-
const [visible, setVisible] = useState(false);
|
|
11
|
-
const tooltip = 'Stop streaming';
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
var _a, _b;
|
|
14
|
-
const writerChanged = (_, writers) => {
|
|
15
|
-
const w = writers.filter(w => w.messageID === message.id);
|
|
16
|
-
if (w.length > 0) {
|
|
17
|
-
setVisible(true);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
setVisible(false);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
// Listen only the messages that are from a bot.
|
|
24
|
-
if (message.sender.username !== ((_a = model.user) === null || _a === void 0 ? void 0 : _a.username) &&
|
|
25
|
-
message.sender.bot) {
|
|
26
|
-
(_b = model.writersChanged) === null || _b === void 0 ? void 0 : _b.connect(writerChanged);
|
|
27
|
-
// Check if the message is currently being edited.
|
|
28
|
-
writerChanged(model, model.writers);
|
|
29
|
-
}
|
|
30
|
-
return () => {
|
|
31
|
-
var _a;
|
|
32
|
-
(_a = model.writersChanged) === null || _a === void 0 ? void 0 : _a.disconnect(writerChanged);
|
|
33
|
-
};
|
|
34
|
-
}, [model]);
|
|
35
|
-
const onClick = () => {
|
|
36
|
-
// Post request to the stop streaming handler.
|
|
37
|
-
requestAPI('api/jupyternaut/chats/stop_streaming', {
|
|
38
|
-
method: 'POST',
|
|
39
|
-
body: JSON.stringify({
|
|
40
|
-
message_id: message.id
|
|
41
|
-
}),
|
|
42
|
-
headers: {
|
|
43
|
-
'Content-Type': 'application/json'
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
return visible ? (React.createElement(TooltippedButton, { onClick: onClick, tooltip: tooltip, buttonProps: {
|
|
48
|
-
size: 'small',
|
|
49
|
-
variant: 'contained',
|
|
50
|
-
title: tooltip
|
|
51
|
-
}, sx: { display: visible ? 'inline-flex' : 'none' } },
|
|
52
|
-
React.createElement(StopIcon, null))) : (React.createElement(React.Fragment, null));
|
|
53
|
-
}
|