Fixed an issue where kernel_id might not be set when using Jupyter as a code interpreter, causing exceptions in the finally block. Additionally, optimized the code structure for better performance and maintainability.
Fixed an issue where incorrect URL concatenation was causing potential kernel closure failures. The improper URL formation was preventing proper communication with the Jupyter kernel, resulting in kernels remaining open after sessions ended.
Screenshots or Videos
Issue
wrong format or url cause 403
kernel_id missing when api is not 200
Testing
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/11120
**Author:** [@U8F69](https://github.com/U8F69)
**Created:** 3/4/2025
**Status:** ✅ Merged
**Merged:** 3/4/2025
**Merged by:** [@tjbck](https://github.com/tjbck)
**Base:** `dev` ← **Head:** `fix_jupyter`
---
### 📝 Commits (5)
- [`744ffbb`](https://github.com/open-webui/open-webui/commit/744ffbb1fbe85c8fa1eedb956a24da3c7aadc272) fix(jupyter): fix kernel_id not set and optimize code
- [`96e0c4d`](https://github.com/open-webui/open-webui/commit/96e0c4d7b81f1e882b74120e962190dfd87ea1b7) refactor(jupyter): replace httpx with aiohttp
- [`613d278`](https://github.com/open-webui/open-webui/commit/613d278afc7e448fec5d4c32d52d0d113361d8e9) refactor(jupyter): change log level
- [`3a7e5a5`](https://github.com/open-webui/open-webui/commit/3a7e5a5f3170b69987813d1767084680f758cb71) feat(jupyter): check response status for destroy kernel
- [`fafd847`](https://github.com/open-webui/open-webui/commit/fafd847f18b24ca3bd6ace6379211debef73b511) refactor(jupyter): change log message for execution failed
### 📊 Changes
**1 file changed** (+170 additions, -129 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/utils/code_interpreter.py` (+170 -129)
</details>
### 📄 Description
### Fixed
- Fixed an issue where kernel_id might not be set when using Jupyter as a code interpreter, causing exceptions in the finally block. Additionally, optimized the code structure for better performance and maintainability.
- Fixed an issue where incorrect URL concatenation was causing potential kernel closure failures. The improper URL formation was preventing proper communication with the Jupyter kernel, resulting in kernels remaining open after sessions ended.
---
### Screenshots or Videos
#### Issue
wrong format or url cause 403
<img width="1488" alt="iShot_2025-03-03_21 25 44" src="https://github.com/user-attachments/assets/60c4e56a-639a-43a1-b31c-820a528808c7" />
kernel_id missing when api is not 200
<img width="946" alt="image" src="https://github.com/user-attachments/assets/3e3d5227-e5a1-4cb3-a6d4-0dbefb7fc8f4" />
#### Testing
<img width="955" alt="image" src="https://github.com/user-attachments/assets/144a752c-eabb-41fe-9b3e-5a33d5c527a9" />
<img width="942" alt="image" src="https://github.com/user-attachments/assets/1b3129d0-dd34-44de-bf31-32a2e4005281" />
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/11120
Author: @U8F69
Created: 3/4/2025
Status: ✅ Merged
Merged: 3/4/2025
Merged by: @tjbck
Base:
dev← Head:fix_jupyter📝 Commits (5)
744ffbbfix(jupyter): fix kernel_id not set and optimize code96e0c4drefactor(jupyter): replace httpx with aiohttp613d278refactor(jupyter): change log level3a7e5a5feat(jupyter): check response status for destroy kernelfafd847refactor(jupyter): change log message for execution failed📊 Changes
1 file changed (+170 additions, -129 deletions)
View changed files
📝
backend/open_webui/utils/code_interpreter.py(+170 -129)📄 Description
Fixed
Screenshots or Videos
Issue
wrong format or url cause 403
kernel_id missing when api is not 200
Testing
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.