Skip to content

Commit

Permalink
feat: 为SearXNGConfig添加额外配置: engines、nums
Browse files Browse the repository at this point in the history
  • Loading branch information
LnYo-Cly committed Dec 18, 2024
1 parent 65cdeb2 commit b503c29
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ai4j-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>io.github.lnyo-cly</groupId>
<artifactId>ai4j-spring-boot-starter</artifactId>
<packaging>jar</packaging>
<version>0.8.0</version>
<version>0.8.1</version>

<name>ai4j-spring-boot-starter</name>
<description>为aj4j所提供的spring-stater,便于接入spring项目。关于ai4j: 一款JavaSDK用于快速接入AI大模型应用,整合多平台大模型,如OpenAi、Ollama、智谱Zhipu(ChatGLM)、深度求索DeepSeek、月之暗面Moonshot(Kimi)、腾讯混元Hunyuan、零一万物(01)、MiniMax、百川Baichuan等等,提供统一的输入输出(对齐OpenAi)消除差异化,优化函数调用(Tool Call),优化RAG调用、支持向量数据库(Pinecone),并且支持JDK1.8,为用户提供快速整合AI的能力。</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ private void initBaichuanConfig() {
private void initSearXNGConfig() {
SearXNGConfig searXNGConfig = new SearXNGConfig();
searXNGConfig.setUrl(searXNGConfigProperties.getUrl());
searXNGConfig.setEngines(searXNGConfigProperties.getEngines());
searXNGConfig.setNums(searXNGConfigProperties.getNums());

configuration.setSearXNGConfig(searXNGConfig);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@
@ConfigurationProperties(prefix = "ai.websearch.searxng")
public class SearXNGConfigProperties {
private String url;
private String engines = "duckduckgo,google,bing,brave,mojeek,presearch,qwant,startpage,yahoo,arxiv,crossref,google_scholar,internetarchivescholar,semantic_scholar";
private int nums = 20;
}
2 changes: 1 addition & 1 deletion ai4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>io.github.lnyo-cly</groupId>
<artifactId>ai4j</artifactId>
<packaging>jar</packaging>
<version>0.8.0</version>
<version>0.8.1</version>

<name>ai4j</name>
<description>一款JavaSDK用于快速接入AI大模型应用,整合多平台大模型,如OpenAi、Ollama、智谱Zhipu(ChatGLM)、深度求索DeepSeek、月之暗面Moonshot(Kimi)、腾讯混元Hunyuan、零一万物(01)、MiniMax、百川Baichuan等等,提供统一的输入输出(对齐OpenAi)消除差异化,优化函数调用(Tool Call),优化RAG调用、支持向量数据库(Pinecone),并且支持JDK1.8,为用户提供快速整合AI的能力。</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ private String performWebSearch(String query) {

SearXNGRequest searXNGRequest = SearXNGRequest.builder()
.q(query)
.engines(searXNGConfig.getEngines())
.build();


Expand All @@ -82,7 +83,7 @@ private String performWebSearch(String query) {


Request request = new Request.Builder()
.url(ValidateUtil.concatUrl(searXNGConfig.getUrl(), "?format=json&q=" + query + "&engines=" + searXNGRequest.getEngines()))
.url(ValidateUtil.concatUrl(searXNGConfig.getUrl(), "?format=json&q=" + query + "&engines=" + searXNGConfig.getEngines()))
.get()
.build();

Expand All @@ -91,8 +92,8 @@ private String performWebSearch(String query) {
if (execute.isSuccessful() && execute.body() != null){
SearXNGResponse searXNGResponse = JSON.parseObject(execute.body().string(), SearXNGResponse.class);

if(searXNGResponse.getResults().size() > 20) {
return JSON.toJSONString(searXNGResponse.getResults().subList(0, 20));
if(searXNGResponse.getResults().size() > searXNGConfig.getNums()) {
return JSON.toJSONString(searXNGResponse.getResults().subList(0, searXNGConfig.getNums()));
}
return JSON.toJSONString(searXNGResponse.getResults());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
@NoArgsConstructor
public class SearXNGConfig {
private String url;
private String engines = "duckduckgo,google,bing,brave,mojeek,presearch,qwant,startpage,yahoo,arxiv,crossref,google_scholar,internetarchivescholar,semantic_scholar";
private int nums = 20;
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>io.github.lnyo-cly</groupId>
<artifactId>ai4j-sdk</artifactId>

<version>0.8.0</version>
<version>0.8.1</version>

<packaging>pom</packaging>

Expand Down

0 comments on commit b503c29

Please sign in to comment.