mirror of
https://github.com/open-webui/open-webui.git
synced 2026-03-24 20:14:58 -05:00
[PR #5378] [MERGED] fix: RAG and Web Search + RAG enhancements #8471
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/5378
Author: @thiswillbeyourgithub
Created: 9/12/2024
Status: ✅ Merged
Merged: 9/13/2024
Merged by: @tjbck
Base:
dev← Head:fix_RAG_and_web📝 Commits (8)
53f03f6fix: log exception when issues of collection queryinged2a1e7enh: use non hybrid search as fallback if hybrid search failed209e246fix: much improved RAG templateadf2678logs: crash if rag_template would be wrong9661feefix: handle case where [query] happens in the RAG contextb4ad645fix: add check that the context for RAG is not empty if the threshold is 0e872f5dlog: added a debug log if detecting a potential prompt injection attack65d5545added a few type hints📊 Changes
3 files changed (+73 additions, -30 deletions)
View changed files
📝
backend/open_webui/apps/rag/utils.py(+52 -20)📝
backend/open_webui/config.py(+16 -10)📝
backend/open_webui/main.py(+5 -0)📄 Description
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
devbranch.Body
I wrote that first as a discussion message then it got out of hand so I did as best as I could to adhere to your format
Disclaimer
I'm extremely happy with Open-WebUI and very enthusiastic about its future and the future of pipelines. Hence, I was quite disappointed by some aspects of the code. I try to explain all of this below but want to clarify that I don't judge any of the maintainers: I can't even begin to imagine what you must have on your plate with a repo of 40k stars. But I still think I found some practices that will most certainly lose you more time than you could gain by coding quickly. I am totally open for discussion on any of the points I raised, I could totally be wrong. And part of all that might be attributed to misunderstandings about what RAG is supposed to do for the user, in which case understanding it here would help clarify the documentation. I will still continue using Open-WebUI and provide accounts for all my community, but want to voice my concerns. To reiterate: my current mindset is the one of a mostly happy user, concerned about some decisions and practices, wanting to do sort of a soft wake up call while remaining respectful of the well being of the maintainers.
Context
RAG and web search were broken for at least weeks. Using langfuse I found out that the
[context]in the RAG template was replaced by an empty string. I also found out that nothing in the code stops that even though I see no reason not to do that.The issue
backend/open_webui/apps/rag/utils.py, inquery_collection_with_hybrid_searchTorch not compiled with CUDA enabled. I don't know why this happened exactly but I's not the purpose of this PR.Additional related issues in this PR
<context>or</context>is present inside the context. I don't know exactly how you want to deal with that. I added a warning anyway. This is NOT to take lightly as pipelines will end up exposing more and more APIs and attackers will always have the edge.Other remarks
Commits in this PR
What this PR fixes
It probably fixes too:
It might also fix
Closing remarks
I'll be blunt but honest: I think that the relative lack of asserts, the fact that exceptions are not shown to the admin, the relative lack of type hints, the apparent lack of test coverage, will progressively increase the burden of developing Open-WebUI as well as make it harder for the community to provide helpful issues, as well as step in and help. I think RAG might have been silently broken for weeks, but maybe many other things are broken without us knowing about it.
Open-WebUI and Pipelines are ambitious, and you need all the help modern developpement practices can bring you!
I now have reasons to doubt that the rest of the codebase is properly checking things, or that anything that breaks is logged.
I think it would be awesome if you added my suggestion regarding showing errors to the admin, then progressively added more asserts as you naturally refactor the code here and there. This might be the most efficient way to go about this as I understand that increasing the test coverage for example requires a significant effort. Also beartype typechecking during the developpement phase or as an opt in for users might be very helpful. (But do use their latest release candidate instead of the latest release.)
Then again, thank you again for making Open-WebUI, it's a great improvement for me and my community. Have a nice day.
PS: While I have your attention, could you share your thoughts about #5323 ? I explained in there that the default RAG model was trained on tweets and silently clips after a few tokens but Open-WebUI's default is still to use that with a 1500 chunk size.
Changelog Entry
Description
RAG and web search were broken for me and I think many others. The fix was to add a fallback to the non hybrid search. While I was at it I saw numerous things I decided to patch, all still related to this issue.
Added
Fixed
Security
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.