Description: Briefly describe the changes in this pull request.
Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
Documentation: Have you updated relevant documentation?
Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
TODOs
Implement database migrations
Update shared chat
Delete shared chat link
Delete shared chat when the original chat gets deleted
Test clean install
Test backward compatibility
Description
Adds the ability to share a chat locally with other authenticated users on the same instance.
This isn't a complete implementation (deletion isn't implemented at the moment), but the design this implements is:
Each chat can have a share_id that points to a chat ID that was the snapshot of the chat when it was shared.
It being a snapshot means that any updates to the original chat will not be reflected in the shared chat
The shared chat is a standard chat DB entry, except with the user_id set to shared to distinguish it from regular chats.
The frontend gets a new route, /s/[id], that is read-only and disables any of the buttons that would modify state.
Things that are unaddressed:
If the original chat is deleted, the shared chat is not deleted.
This applies to all mechanisms of deletion, such as deleting by chat id, or deleting all of a user's chats.
There is no mechanism in the frontend to update an already shared chat
There is no mechanism in the frontend to delete a shared chat
Do we want to make it possible for unauthenticated users to view shared chats, ie a public sharing option? I think this use case is currently addressed by the share to openwebui.com option, but people might have a stronger feeling towards data residency?
A potential feature is to allow a user to continue the shared chat.
📩Local Sharing: Share your chats with other users on your Open WebUI instance
🔄 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/1364
**Author:** [@cheahjs](https://github.com/cheahjs)
**Created:** 3/31/2024
**Status:** ✅ Merged
**Merged:** 4/2/2024
**Merged by:** [@tjbck](https://github.com/tjbck)
**Base:** `dev` ← **Head:** `feat/local-sharing`
---
### 📝 Commits (10+)
- [`86aa2ca`](https://github.com/open-webui/open-webui/commit/86aa2ca6cb14df2399f8297726a3bd978ab3d541) Merge pull request #1363 from open-webui/dev
- [`bfbfdae`](https://github.com/open-webui/open-webui/commit/bfbfdae1c5c8aa2f5b94d7f9738d70b061b4abe2) feat: add backend functions for sharing chats
- [`196f91d`](https://github.com/open-webui/open-webui/commit/196f91d68c9211a37f9d902ef50a6f3cfcb187fa) feat: add frontend support for locally sharing chats
- [`edeff20`](https://github.com/open-webui/open-webui/commit/edeff20e1d0b5aba10f46b26f01e08cd28ac48be) Merge pull request #1374 from open-webui/dev
- [`4cb2cc6`](https://github.com/open-webui/open-webui/commit/4cb2cc62d245617fa178702df99852deccb3e15a) feat: add ability to run db migrations
- [`d667fae`](https://github.com/open-webui/open-webui/commit/d667faea33f1079094d891583bc248c067371ac6) feat: migrate db schema for local sharing
- [`77b1edc`](https://github.com/open-webui/open-webui/commit/77b1edcd0fef991f76c6e4db07d547484f64390c) fix: allowed hosts
- [`554e566`](https://github.com/open-webui/open-webui/commit/554e56687ccbc6903210c0f8e1cd9a8281b61776) Merge pull request from GHSA-39wr-r5vm-3jxj
- [`6c96361`](https://github.com/open-webui/open-webui/commit/6c963614026137df92b666997d94267c98c32e24) Suggested mitigation for KL-CAN-2024-002.
- [`d72653c`](https://github.com/open-webui/open-webui/commit/d72653cdea760be3908dfe82fd1ec84e1dfa48ca) fix: download allowed hosts
### 📊 Changes
**22 files changed** (+1045 additions, -208 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/apps/ollama/main.py` (+15 -0)
📝 `backend/apps/rag/main.py` (+18 -1)
📝 `backend/apps/web/internal/db.py` (+4 -1)
➕ `backend/apps/web/internal/migrations/001_initial_schema.py` (+149 -0)
➕ `backend/apps/web/internal/migrations/002_add_local_sharing.py` (+48 -0)
➕ `backend/apps/web/internal/migrations/README.md` (+21 -0)
📝 `backend/apps/web/models/chats.py` (+93 -1)
📝 `backend/apps/web/routers/chats.py` (+72 -0)
📝 `backend/main.py` (+15 -0)
📝 `backend/requirements.txt` (+1 -0)
📝 `src/lib/apis/chats/index.ts` (+96 -0)
📝 `src/lib/components/chat/Messages.svelte` (+3 -0)
📝 `src/lib/components/chat/Messages/ResponseMessage.svelte` (+84 -78)
📝 `src/lib/components/chat/Messages/UserMessage.svelte` (+27 -24)
📝 `src/lib/components/chat/Settings/Models.svelte` (+3 -0)
📝 `src/lib/components/chat/ShareChatModal.svelte` (+162 -23)
➕ `src/lib/components/icons/Link.svelte` (+16 -0)
📝 `src/lib/components/layout/Navbar.svelte` (+7 -49)
📝 `src/lib/i18n/locales/nl-NL/translation.json` (+29 -29)
📝 `src/routes/(app)/+page.svelte` (+1 -1)
_...and 2 more files_
</details>
### 📄 Description
## Pull Request Checklist
- [x] **Description:** Briefly describe the changes in this pull request.
- [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description.
- [ ] **Documentation:** Have you updated relevant documentation?
- [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation?
---
## TODOs
- [x] Implement database migrations
- [x] Update shared chat
- [x] Delete shared chat link
- [x] Delete shared chat when the original chat gets deleted
- [x] Test clean install
- [x] Test backward compatibility
## Description
Adds the ability to share a chat locally with other authenticated users on the same instance.
This isn't a complete implementation (deletion isn't implemented at the moment), but the design this implements is:
1. Each chat can have a `share_id` that points to a chat ID that was the snapshot of the chat when it was shared.
* It being a snapshot means that any updates to the original chat will not be reflected in the shared chat
2. The shared chat is a standard chat DB entry, except with the `user_id` set to `shared` to distinguish it from regular chats.
3. The frontend gets a new route, `/s/[id]`, that is read-only and disables any of the buttons that would modify state.
Things that are unaddressed:
1. If the original chat is deleted, the shared chat is not deleted.
* This applies to all mechanisms of deletion, such as deleting by chat id, or deleting all of a user's chats.
2. There is no mechanism in the frontend to update an already shared chat
3. There is no mechanism in the frontend to delete a shared chat
5. Do we want to make it possible for unauthenticated users to view shared chats, ie a public sharing option? I think this use case is currently addressed by the share to openwebui.com option, but people might have a stronger feeling towards data residency?
6. A potential feature is to allow a user to continue the shared chat.
* For example, on Poe <img width="833" alt="image" src="https://github.com/open-webui/open-webui/assets/818368/0d3f202b-eb31-4925-afe1-16b464c40378">
https://github.com/open-webui/open-webui/assets/818368/0fa1afe6-05c8-495e-937d-180953239d47
May address https://github.com/open-webui/open-webui/issues/797
---
### Changelog Entry
### Added
- 📩 **Local Sharing**: Share your chats with other users on your Open WebUI instance
---
<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/1364
Author: @cheahjs
Created: 3/31/2024
Status: ✅ Merged
Merged: 4/2/2024
Merged by: @tjbck
Base:
dev← Head:feat/local-sharing📝 Commits (10+)
86aa2caMerge pull request #1363 from open-webui/devbfbfdaefeat: add backend functions for sharing chats196f91dfeat: add frontend support for locally sharing chatsedeff20Merge pull request #1374 from open-webui/dev4cb2cc6feat: add ability to run db migrationsd667faefeat: migrate db schema for local sharing77b1edcfix: allowed hosts554e566Merge pull request from GHSA-39wr-r5vm-3jxj6c96361Suggested mitigation for KL-CAN-2024-002.d72653cfix: download allowed hosts📊 Changes
22 files changed (+1045 additions, -208 deletions)
View changed files
📝
backend/apps/ollama/main.py(+15 -0)📝
backend/apps/rag/main.py(+18 -1)📝
backend/apps/web/internal/db.py(+4 -1)➕
backend/apps/web/internal/migrations/001_initial_schema.py(+149 -0)➕
backend/apps/web/internal/migrations/002_add_local_sharing.py(+48 -0)➕
backend/apps/web/internal/migrations/README.md(+21 -0)📝
backend/apps/web/models/chats.py(+93 -1)📝
backend/apps/web/routers/chats.py(+72 -0)📝
backend/main.py(+15 -0)📝
backend/requirements.txt(+1 -0)📝
src/lib/apis/chats/index.ts(+96 -0)📝
src/lib/components/chat/Messages.svelte(+3 -0)📝
src/lib/components/chat/Messages/ResponseMessage.svelte(+84 -78)📝
src/lib/components/chat/Messages/UserMessage.svelte(+27 -24)📝
src/lib/components/chat/Settings/Models.svelte(+3 -0)📝
src/lib/components/chat/ShareChatModal.svelte(+162 -23)➕
src/lib/components/icons/Link.svelte(+16 -0)📝
src/lib/components/layout/Navbar.svelte(+7 -49)📝
src/lib/i18n/locales/nl-NL/translation.json(+29 -29)📝
src/routes/(app)/+page.svelte(+1 -1)...and 2 more files
📄 Description
Pull Request Checklist
TODOs
Description
Adds the ability to share a chat locally with other authenticated users on the same instance.
This isn't a complete implementation (deletion isn't implemented at the moment), but the design this implements is:
share_idthat points to a chat ID that was the snapshot of the chat when it was shared.user_idset tosharedto distinguish it from regular chats./s/[id], that is read-only and disables any of the buttons that would modify state.Things that are unaddressed:
https://github.com/open-webui/open-webui/assets/818368/0fa1afe6-05c8-495e-937d-180953239d47
May address https://github.com/open-webui/open-webui/issues/797
Changelog Entry
Added
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.