Skip to content

Commit 5477c01

Browse files
committed
fix bing chat
1 parent 7ec56fa commit 5477c01

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pip uninstall jupyter_stack_trace
3131

3232
Jupyter is only able to access files in the directory in which it is run or a subdirectory. Therefore, to be able to open a file in the stack trace, it is necessary to provide a soft link from the Jupyter launch directory to package source directories.
3333

34-
Make a soft link in the Jupyter launch directory to a base directory of your Python instalation (e.g., `~/.local/lib/python3.10`) and call this `python3.10`. Then add the prefix `~/.local/lib` in the `jupyter-stack-trace` settings. If you use `pipenv`, for example, then also make a soft link to the `~/.local/share/virtualenvs` called `virtualenvs` and add the prefix `~/.local/share`.
34+
Make a soft link in the Jupyter launch directory to a base directory of your Python installation (e.g., `~/.local/lib/python3.10`) and call this `python3.10`. Then add the prefix `~/.local/lib` in the `jupyter-stack-trace` settings. If you use `pipenv`, for example, then also make a soft link to the `~/.local/share/virtualenvs` called `virtualenvs` and add the prefix `~/.local/share`.
3535

3636
The exact configuration will depend on your setup, but if you find that clicking a filename in the stack trace does not open up the file, then make the soft link to a point somewhere higher up the path and add the corresponding prefix in the settings.
3737

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jupyter-stack-trace",
3-
"version": "0.1.6",
3+
"version": "0.1.7",
44
"description": "A JupyterLab extension to jump to the line in the file of the stack trace.",
55
"keywords": [
66
"jupyter",

src/index.ts

+15-10
Original file line numberDiff line numberDiff line change
@@ -101,25 +101,30 @@ const plugin: JupyterFrontEndPlugin<void> = {
101101
outputs.forEach((output: IOutput) => {
102102
if (output.output_type === 'error') {
103103
const stackTrace: string[] = (output.traceback as string[]) ?? [];
104-
const escapedStackTraces = stackTrace.map(item =>
105-
escape(
106-
// eslint-disable-next-line no-control-regex
107-
item.replace(/\x1b\[(.*?)([@-~])/g, '')
108-
)
104+
const colourlessStackTraces = stackTrace.map(item =>
105+
// eslint-disable-next-line no-control-regex
106+
item.replace(/\x1b\[(.*?)([@-~])/g, '')
109107
);
110108

111109
const stackOverflowUrl =
112-
'https://google.com/search?q=' +
113-
escapedStackTraces[escapedStackTraces.length - 1] +
110+
'https://google.com/search?' +
111+
new URLSearchParams({
112+
sendquery: '1',
113+
q: colourlessStackTraces[colourlessStackTraces.length - 1]
114+
}).toString() +
114115
'+site:stackoverflow.com';
115116
const stackOverflowButton =
116117
'<button class="stack-trace-btn" onclick="window.open(\'' +
117118
stackOverflowUrl +
118119
"', '_blank');\">Search Stack Overflow</button>";
119120
const bingChatUrl =
120-
'https://www.bing.com/chat?iscopilotedu=1&sendquery=1&q=' +
121-
escape('Please help me with the following error:\n') +
122-
escapedStackTraces.join('%0A');
121+
'https://www.bing.com/chat?' +
122+
new URLSearchParams({
123+
sendquery: '1',
124+
q:
125+
'Please help me with the following error:\n' +
126+
colourlessStackTraces.join('\n')
127+
}).toString();
123128
const bingButton =
124129
'<button class="stack-trace-btn" onclick="window.open(\'' +
125130
bingChatUrl +

0 commit comments

Comments
 (0)