当前位置: 首页 > article >正文

[原创]openwebui解决searxng通过接口请求不成功问题

openwebui 对接 searxng 时 无法查询到联网信息,使用bing搜索,每次返回json是正常的

神秘代码:

http://172.30.254.200:8080/search?q=北京市天气&format=json&language=zh&time_range=&safesearch=0&language=zh&locale=zh-Hans-CN&autocomplete=&favicon_resolver=&image_proxy=0&method=POST&safesearch=0&theme=simple&results_on_new_tab=0&doi_resolver=oadoi.org&simple_style=auto&center_alignment=0&advanced_search=0&query_in_title=0&infinite_scroll=0&search_on_category_select=1&hotkeys=default&url_formatting=pretty&disabled_plugins=&enabled_plugins=&tokens=&categories=general&disabled_engines="wikipedia__general\054currency__general\054wikidata__general\054duckduckgo__general\054google__general\054lingva__general\054qwant__general\054startpage__general\054dictzone__general\054mymemory translated__general\054brave__general"&enabled_engines=bing__general

官方教程是这样设置的  非常不稳定,经常搜索不到结果

 searxng.py 源码 调整前

import logging
from typing import Optionalimport requests
from open_webui.retrieval.web.main import SearchResult, get_filtered_results
from open_webui.env import SRC_LOG_LEVELSlog = logging.getLogger(__name__)
log.setLevel(SRC_LOG_LEVELS["RAG"])def search_searxng(query_url: str,query: str,count: int,filter_list: Optional[list[str]] = None,**kwargs,
) -> list[SearchResult]:"""Search a SearXNG instance for a given query and return the results as a list of SearchResult objects.The function allows passing additional parameters such as language or time_range to tailor the search result.Args:query_url (str): The base URL of the SearXNG server.query (str): The search term or question to find in the SearXNG database.count (int): The maximum number of results to retrieve from the search.Keyword Args:language (str): Language filter for the search results; e.g., "en-US". Defaults to an empty string.safesearch (int): Safe search filter for safer web results; 0 = off, 1 = moderate, 2 = strict. Defaults to 1 (moderate).time_range (str): Time range for filtering results by date; e.g., "2023-04-05..today" or "all-time". Defaults to ''.categories: (Optional[list[str]]): Specific categories within which the search should be performed, defaulting to an empty string if not provided.Returns:list[SearchResult]: A list of SearchResults sorted by relevance score in descending order.Raise:requests.exceptions.RequestException: If a request error occurs during the search process."""# Default values for optional parameters are provided as empty strings or None when not specified.language = kwargs.get("language", "en-US")safesearch = kwargs.get("safesearch", "1")time_range = kwargs.get("time_range", "")categories = "".join(kwargs.get("categories", []))params = {"q": query,"format": "json","pageno": 1,"safesearch": safesearch,"language": language,"time_range": time_range,"categories": categories,"theme": "simple","image_proxy": 0,}# Legacy query formatif "<query>" in query_url:# Strip all query parameters from the URLquery_url = query_url.split("?")[0]log.debug(f"searching {query_url}")response = requests.get(query_url,headers={"User-Agent": "Open WebUI (https://github.com/open-webui/open-webui) RAG Bot","Accept": "text/html","Accept-Encoding": "gzip, deflate","Accept-Language": "en-US,en;q=0.5","Connection": "keep-alive",},params=params,)response.raise_for_status()  # Raise an exception for HTTP errors.json_response = response.json()results = json_response.get("results", [])sorted_results = sorted(results, key=lambda x: x.get("score", 0), reverse=True)if filter_list:sorted_results = get_filtered_results(sorted_results, filter_list)return [SearchResult(link=result["url"], title=result.get("title"), snippet=result.get("content"))for result in sorted_results[:count]]

 调整后

import logging
from typing import Optionalimport requests
from open_webui.retrieval.web.main import SearchResult, get_filtered_results
from open_webui.env import SRC_LOG_LEVELSlog = logging.getLogger(__name__)
log.setLevel(SRC_LOG_LEVELS["RAG"])def search_searxng(query_url: str,query: str,count: int,filter_list: Optional[list[str]] = None,**kwargs,
) -> list[SearchResult]:"""Search a SearXNG instance for a given query and return the results as a list of SearchResult objects.The function allows passing additional parameters such as language or time_range to tailor the search result.Args:query_url (str): The base URL of the SearXNG server.query (str): The search term or question to find in the SearXNG database.count (int): The maximum number of results to retrieve from the search.Keyword Args:language (str): Language filter for the search results; e.g., "en-US". Defaults to an empty string.safesearch (int): Safe search filter for safer web results; 0 = off, 1 = moderate, 2 = strict. Defaults to 1 (moderate).time_range (str): Time range for filtering results by date; e.g., "2023-04-05..today" or "all-time". Defaults to ''.categories: (Optional[list[str]]): Specific categories within which the search should be performed, defaulting to an empty string if not provided.Returns:list[SearchResult]: A list of SearchResults sorted by relevance score in descending order.Raise:requests.exceptions.RequestException: If a request error occurs during the search process."""# Default values for optional parameters are provided as empty strings or None when not specified.language = kwargs.get("language", "zh")safesearch = kwargs.get("safesearch", "1")time_range = kwargs.get("time_range", "")categories = "".join(kwargs.get("categories", []))params = {"q": query,"format": "json","pageno": 1,"safesearch": safesearch,"language": language,"time_range": time_range,"categories": categories,"theme": "simple","image_proxy": 0,"locale":"zh-Hans-CN",        "disabled_engines":"wikipedia__general\054currency__general\054wikidata__general\054duckduckgo__general\054google__general\054lingva__general\054qwant__general\054startpage__general\054dictzone__general\054mymemory translated__general\054brave__general","enabled_engines":"bing__general"}# Legacy query formatif "<query>" in query_url:# Strip all query parameters from the URLquery_url = query_url.split("?")[0]log.debug(f"searching {query_url}")response = requests.get(query_url,headers={"User-Agent": "Open WebUI (https://github.com/open-webui/open-webui) RAG Bot","Accept": "text/html","Accept-Encoding": "gzip, deflate","Accept-Language": "en-US,en;q=0.5","Connection": "keep-alive",},params=params,)response.raise_for_status()  # Raise an exception for HTTP errors.json_response = response.json()results = json_response.get("results", [])sorted_results = sorted(results, key=lambda x: x.get("score", 0), reverse=True)if filter_list:sorted_results = get_filtered_results(sorted_results, filter_list)return [SearchResult(link=result["url"], title=result.get("title"), snippet=result.get("content"))for result in sorted_results[:count]]

 改完 看到请求参数

总结   openwebui 对接SearXNG 有bug 我修不来 ,提出的关键词就会被修改掉为什么呢?

接着搞,把搜索关键字写死

 出结果了

 

 实际搜索到网页是正确的,结果就 是不行,是模型问题还是openwebui问题?

搞不来了,放弃 

相关文章:

[原创]openwebui解决searxng通过接口请求不成功问题

openwebui 对接 searxng 时 无法查询到联网信息&#xff0c;使用bing搜索&#xff0c;每次返回json是正常的 神秘代码&#xff1a; http://172.30.254.200:8080/search?q北京市天气&formatjson&languagezh&time_range&safesearch0&languagezh&locale…...

8 SpringBootWeb(下):登录效验、异步任务和多线程、SpringBoot中的事务管理@Transactional

文章目录 案例-登录认证1. 登录功能1.1 需求1.2 接口文档1.3 思路分析1.4 功能开发1.5 测试2. 登录校验2.1 问题分析2.2 会话技术2.2.1 会话技术介绍2.2.2 会话跟踪方案2.2.2.1 方案一 - Cookie2.2.2.2 方案二 - Session2.2.2.3 方案三 - 令牌技术2.2.3 JWT令牌(Token)2.2.3.…...

2025年山东省职业院校技能大赛(高职组)“云计算应用”赛项赛卷1

“云计算应用”赛项赛卷1 2025年山东省职业院校技能大赛&#xff08;高职组&#xff09;“云计算应用”赛项赛卷1模块一 私有云&#xff08;30分&#xff09;任务1 私有云服务搭建&#xff08;5分&#xff09;1.1.1 基础环境配置1.1.2 yum源配置1.1.3 配置无秘钥ssh1.1.4 基础安…...

MySQL数据库基本概念

目录 什么是数据库 从软件角度出发 从网络角度出发 MySQL数据库的client端和sever端进程 mysql的client端进程连接sever端进程 mysql配置文件 MySql存储引擎 MySQL的sql语句的分类 数据库 库的操作 创建数据库 不同校验规则对查询的数据的影响 不区分大小写 区…...

塔能科技:工厂智慧照明,从底层科技实现照明系统的智能化控制

在全球节能减碳和智慧生活需求激增的背景下&#xff0c;基于“用软件定义硬件&#xff0c;让物联运维更简捷更节能”的产品理念&#xff0c;塔能科技的智慧照明一体化方案如新星般崛起&#xff0c;引领照明行业新方向。现在&#xff0c;我们来深入探究其背后的创新技术。该方案…...

P3398 仓鼠找 sugar【题解】

这是LCA的一个应用&#xff0c;关于LCA P3398 仓鼠找 sugar 题目描述 小仓鼠的和他的基&#xff08;mei&#xff09;友&#xff08;zi&#xff09;sugar 住在地下洞穴中&#xff0c;每个节点的编号为 1 ∼ n 1\sim n 1∼n。地下洞穴是一个树形结构。这一天小仓鼠打算从从他…...

解决VirtualBox - Error In supR3HardenedWinReSpawn报错

问题描述 VirtualBox7.1.6启动虚拟机时报错&#xff1a; Error In supR3HardenedWinReSpawn NtCreateFile(\Device\VBoxDrvStub) failed: 0xc000000034 STATUS_OBJECT_NAME_NOT_FOUND (0 retries) (rc-101) Make sure the kernel module has been loaded successfully.原因分…...

Android Trace埋点beginSection打tag标签,Kotlin

Android Trace埋点beginSection打tag标签&#xff0c;Kotlin import android.os.Bundle import android.os.Trace import android.util.Log import androidx.appcompat.app.AppCompatActivityclass ImageActivity : AppCompatActivity() {companion object {const val TRACE_TA…...

Linux上用C++和GCC开发程序实现两个不同MySQL实例下单个Schema稳定高效的数据迁移到其它MySQL实例

设计一个在Linux上运行的GCC C程序&#xff0c;同时连接三个不同的MySQL实例&#xff0c;其中两个实例中分别有两个Schema的表结构分别与第三实例中两个Schema个结构完全相同&#xff0c;同时复制两个实例中两个Schema里的所有表的数据到第三个实例中两个Schema里&#xff0c;使…...

Lua的table(表)

Lua表的基本概念 Lua中的表&#xff08;table&#xff09;是一种多功能数据结构&#xff0c;可以用作数组、字典、集合等。表是Lua中唯一的数据结构机制&#xff0c;其他数据结构如数组、列表、队列等都可以通过表来实现。 表的实现 Lua的表由两部分组成&#xff1a; 数组部分…...

51页精品PPT | 农产品区块链溯源信息化平台整体解决方案

PPT展示了一个基于区块链技术的农产品溯源信息化平台的整体解决方案。它从建设背景和需求分析出发&#xff0c;强调了农产品质量安全溯源的重要性以及国际国内的相关政策要求&#xff0c;指出了食品安全问题在流通环节中的根源。方案提出了全面感知、责任到人、定期考核和追溯反…...

Jenkins 自动打包项目镜像部署到服务器 ---(前端项目)

Jenkins 新增前端项目Job 指定运行的节点 选择部署运行的节点标签&#xff0c;dev标签对应开发环境 节点的远程命令执行配置 jenkins完整流程 配置源码 拉取 Credentials添加 触发远程构建 配置后可以支持远程触发jenkins构建&#xff08;比如自建的CICD自动化发布平台&…...

使用AoT让.NetFramework4.7.2程序调用.Net8编写的库

1、创建.Net8的库&#xff0c;双击解决方案中的项目&#xff0c;修改如下&#xff0c;启用AoT&#xff1a; <Project Sdk"Microsoft.NET.Sdk"><PropertyGroup><OutputType>Library</OutputType><PublishAot>true</PublishAot>&…...

第49天:Web开发-JavaEE应用SpringBoot栈模版注入ThymeleafFreemarkerVelocity

#知识点 1、安全开发-JavaEE-开发框架-SpringBoot&路由&传参 2、安全开发-JavaEE-模版引擎-Thymeleaf&Freemarker&Velocity 一、开发框架-SpringBoot 参考&#xff1a;https://springdoc.cn/spring-boot/ 访问SpringBoot创建的网站 1、路由映射 RequestMapping…...

学习笔记08——ConcurrentHashMap实现原理及源码解析

1. 概述 为什么需要ConcurrentHashMap&#xff1f; 解决HashMap线程不安全问题&#xff1a;多线程put可能导致死循环&#xff08;JDK7&#xff09;、数据覆盖&#xff08;JDK8&#xff09; 优化HashTable性能&#xff1a;通过细粒度锁替代全局锁&#xff0c;提高并发度 对比…...

数据集笔记:NUSMods API

1 介绍 NUSMods API 包含用于渲染 NUSMods 的数据。这些数据包括新加坡国立大学&#xff08;NUS&#xff09;提供的课程以及课程表的信息&#xff0c;还包括上课地点的详细信息。 可以使用并实验这些数据&#xff0c;它们是从教务处提供的官方 API 中提取的。 该 API 由静态的…...

SpringBoot新闻推荐系统设计与实现

随着信息时代的快速发展&#xff0c;新闻推荐系统成为用户获取个性化内容的重要工具。本文将介绍一个幽络源的基于SpringBoot开发的新闻推荐系统&#xff0c;该系统功能全面&#xff0c;操作简便&#xff0c;能够满足管理员和用户的多种需求。 管理员模块 管理员模块为系统管…...

谷歌推出PaliGemma 2 mix:用于多任务的视觉语言模型,开箱即用。

去年 12 月&#xff0c;谷歌推出了 PaliGemma 2 &#xff0c;这是Gemma系列中的升级版视觉语言模型。该版本包含不同大小&#xff08;3B、10B 和 28B 参数&#xff09;的预训练检查点&#xff0c;可轻松针对各种视觉语言任务和领域进行微调&#xff0c;例如图像分割、短视频字幕…...

深入浅出Spring Boot框架:从入门到精通

引言 在现代软件开发中&#xff0c;Java 语言及其生态系统一直是构建企业级应用的首选之一。Spring Boot 是 Java 社区中最具影响力的项目之一&#xff0c;它继承了 Spring 框架的优点&#xff0c;并通过简化配置和加速开发流程&#xff0c;使得开发者能够更加专注于业务逻辑的…...

Spring Boot spring-boot-maven-plugin 参数配置详解

一 spring-boot-maven-plugin 插件的5个Goals spring-boot:repackage&#xff0c;默认goal。在mvn package之后&#xff0c;再次打包可执行的jar/war&#xff0c;同时保留mvn package生成的jar/war为.origin&#xff1b;重新打包存在的jar或者war包从而使他们可以在命令行使用…...

linux中断调用流程(arm)

文章目录 ARM架构下Linux中断处理全流程解析&#xff1a;从硬件触发到驱动调用 ⚡**一、中断触发与硬件层响应** &#x1f50c;**1. 设备触发中断** &#x1f4e1; **二、CPU阶段&#xff1a;异常入口与上下文处理** &#x1f5a5;️**1. 异常模式切换** &#x1f504;**2. 跳转…...

考研复试问题总结-数据结构(1)

1. 说一下你对数据结构的理解 我觉得数据结构不仅仅是存数据的“容器”&#xff0c;更是一种思维方式。其实&#xff0c;在我们写程序时&#xff0c;经常会遇到各种各样的数据操作需求&#xff0c;而不同的数据结构能解决问题的效率和方式都不一样&#xff0c;所以选择合适的数…...

250301-OpenWebUI配置DeepSeek-火山方舟+硅基流动+联网搜索+推理显示

A. 最终效果 B. 火山方舟配置&#xff08;一定要点击添加&#xff09; C. 硅基流动配置&#xff08;最好要点击添加&#xff0c;否则会自动弹出所有模型&#xff09; D. 联网搜索配置 E. 推理过程显示 默认是没有下面的推理过程的显示的 设置步骤&#xff1a; 在Functions函…...

RuoYi框架介绍,以及如何基于Python使用RuoYi框架

若依框架&#xff08;RuoYi&#xff09;是一款基于Spring Boot和Vue.js的开源快速开发平台&#xff0c;广泛应用于企业级应用开发。它提供了丰富的功能模块和代码生成工具&#xff0c;帮助开发者快速搭建后台管理系统。 主要特点 前后端分离&#xff1a;前端采用Vue.js&#x…...

【算法】图论 —— Floyd算法 python

洛谷 B3647 【模板】Floyd 题目描述 给出一张由 n n n 个点 m m m 条边组成的无向图。 求出所有点对 ( i , j ) (i,j) (i,j) 之间的最短路径。 输入格式 第一行为两个整数 n , m n,m n,m&#xff0c;分别代表点的个数和边的条数。 接下来 m m m 行&#xff0c;每行三…...

2.数据结构:2.最大异或对

数据结构 2.数据结构&#xff1a;1.Tire 字符串统计 当前题 最大异或对 #include<algorithm> #include<cstring> #include<iostream>using namespace std;const int N100010,M31*N;// M 表示节点个数&#xff0c;每一个数最多有 31 位int n; int a[N]; i…...

剑指 Offer II 031. 最近最少使用缓存

comments: true edit_url: https://github.com/doocs/leetcode/edit/main/lcof2/%E5%89%91%E6%8C%87%20Offer%20II%20031.%20%E6%9C%80%E8%BF%91%E6%9C%80%E5%B0%91%E4%BD%BF%E7%94%A8%E7%BC%93%E5%AD%98/README.md 剑指 Offer II 031. 最近最少使用缓存 题目描述 运用所掌握的…...

Windows 11【1001问】查看Windows 11 版本的18种方法

随着技术的飞速发展&#xff0c;操作系统作为连接硬件与软件的核心桥梁&#xff0c;其版本管理和更新变得尤为重要。对于用户而言&#xff0c;了解自己设备上运行的具体Windows 11版本不仅有助于优化系统性能&#xff0c;还能确保安全性和兼容性。然而&#xff0c;不同场景和需…...

小程序性能优化-预加载

在微信小程序中&#xff0c;数据预加载是提升用户体验的重要优化手段。以下是处理数据预加载的完整方案&#xff1a; 一、预加载的适用场景 跳转页面前的数据准备 如从列表页进入详情页前&#xff0c;提前加载详情数据首屏加载后的空闲时间 在首页加载完成后&#xff0c;预加载…...

vue3中展示markdown格式文章的三种形式

一、安装 # 使用 npm npm i kangc/v-md-editor -S# 使用yarn yarn add kangc/v-md-editor二、三种实现形式 1、编辑器的只读模式 main.ts文件中配置&#xff1a; import VMdEditor from kangc/v-md-editor; import kangc/v-md-editor/lib/style/base-editor.css;const app …...