mirror of
https://github.com/open-webui/open-webui
synced 2025-05-24 14:54:33 +00:00
Merge pull request #9416 from abdalrohman/fix_filter_domains
feat(ui): implement domain filter list for web search settings
This commit is contained in:
commit
3c5ac4ace5
@ -392,6 +392,7 @@ async def get_rag_config(request: Request, user=Depends(get_admin_user)):
|
|||||||
"exa_api_key": request.app.state.config.EXA_API_KEY,
|
"exa_api_key": request.app.state.config.EXA_API_KEY,
|
||||||
"result_count": request.app.state.config.RAG_WEB_SEARCH_RESULT_COUNT,
|
"result_count": request.app.state.config.RAG_WEB_SEARCH_RESULT_COUNT,
|
||||||
"concurrent_requests": request.app.state.config.RAG_WEB_SEARCH_CONCURRENT_REQUESTS,
|
"concurrent_requests": request.app.state.config.RAG_WEB_SEARCH_CONCURRENT_REQUESTS,
|
||||||
|
"domain_filter_list": request.app.state.config.RAG_WEB_SEARCH_DOMAIN_FILTER_LIST,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -441,6 +442,7 @@ class WebSearchConfig(BaseModel):
|
|||||||
exa_api_key: Optional[str] = None
|
exa_api_key: Optional[str] = None
|
||||||
result_count: Optional[int] = None
|
result_count: Optional[int] = None
|
||||||
concurrent_requests: Optional[int] = None
|
concurrent_requests: Optional[int] = None
|
||||||
|
domain_filter_list: Optional[List[str]] = []
|
||||||
|
|
||||||
|
|
||||||
class WebConfig(BaseModel):
|
class WebConfig(BaseModel):
|
||||||
@ -553,6 +555,9 @@ async def update_rag_config(
|
|||||||
request.app.state.config.RAG_WEB_SEARCH_CONCURRENT_REQUESTS = (
|
request.app.state.config.RAG_WEB_SEARCH_CONCURRENT_REQUESTS = (
|
||||||
form_data.web.search.concurrent_requests
|
form_data.web.search.concurrent_requests
|
||||||
)
|
)
|
||||||
|
request.app.state.config.RAG_WEB_SEARCH_DOMAIN_FILTER_LIST = (
|
||||||
|
form_data.web.search.domain_filter_list
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"status": True,
|
"status": True,
|
||||||
@ -599,6 +604,7 @@ async def update_rag_config(
|
|||||||
"exa_api_key": request.app.state.config.EXA_API_KEY,
|
"exa_api_key": request.app.state.config.EXA_API_KEY,
|
||||||
"result_count": request.app.state.config.RAG_WEB_SEARCH_RESULT_COUNT,
|
"result_count": request.app.state.config.RAG_WEB_SEARCH_RESULT_COUNT,
|
||||||
"concurrent_requests": request.app.state.config.RAG_WEB_SEARCH_CONCURRENT_REQUESTS,
|
"concurrent_requests": request.app.state.config.RAG_WEB_SEARCH_CONCURRENT_REQUESTS,
|
||||||
|
"domain_filter_list": request.app.state.config.RAG_WEB_SEARCH_DOMAIN_FILTER_LIST,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,14 @@
|
|||||||
let youtubeProxyUrl = '';
|
let youtubeProxyUrl = '';
|
||||||
|
|
||||||
const submitHandler = async () => {
|
const submitHandler = async () => {
|
||||||
|
// Convert domain filter string to array before sending
|
||||||
|
if (webConfig?.search?.domain_filter_list) {
|
||||||
|
webConfig.search.domain_filter_list = webConfig.search.domain_filter_list
|
||||||
|
.split(',')
|
||||||
|
.map(domain => domain.trim())
|
||||||
|
.filter(domain => domain.length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
const res = await updateRAGConfig(localStorage.token, {
|
const res = await updateRAGConfig(localStorage.token, {
|
||||||
web: webConfig,
|
web: webConfig,
|
||||||
youtube: {
|
youtube: {
|
||||||
@ -49,6 +57,10 @@
|
|||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
webConfig = res.web;
|
webConfig = res.web;
|
||||||
|
// Convert array back to comma-separated string for display
|
||||||
|
if (webConfig?.search?.domain_filter_list) {
|
||||||
|
webConfig.search.domain_filter_list = webConfig.search.domain_filter_list.join(', ');
|
||||||
|
}
|
||||||
|
|
||||||
youtubeLanguage = res.youtube.language.join(',');
|
youtubeLanguage = res.youtube.language.join(',');
|
||||||
youtubeTranslation = res.youtube.translation;
|
youtubeTranslation = res.youtube.translation;
|
||||||
@ -334,6 +346,18 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-2">
|
||||||
|
<div class=" self-center text-xs font-medium mb-1">
|
||||||
|
{$i18n.t('Domain Filter List')}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input
|
||||||
|
class="w-full rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-none"
|
||||||
|
placeholder={$i18n.t('Enter domains separated by commas (e.g., example.com,site.org)')}
|
||||||
|
bind:value={webConfig.search.domain_filter_list}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user