这是indexloc提供的服务,不要输入任何密码
Skip to content

feat: 更新文件搜索工具类及测试用例 #61 #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.theokanning.openai.assistants.assistant;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* @author LiangTao
* @date 2024年09月19 10:53
**/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class FileSearch {
/**
* The maximum number of results the file search tool should output. The default is 20 for gpt-4* models and 5 for gpt-3.5-turbo. This number should be between 1 and 50 inclusive.
*/
@JsonProperty("max_num_results")
Integer maxNumResults;

/**
* The ranking options for the file search. If not specified, the file search tool will use the auto ranker and a score_threshold of 0.
*/
@JsonProperty("ranking_options")
FileSearchRankingOptions rankingOptions;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.theokanning.openai.assistants.assistant;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;

/**
* @author LiangTao
* @date 2024年09月19 10:36
**/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FileSearchRankingOptions {
/**
* The ranker to use for the file search. If not specified will use the auto ranker.
*/
String ranker;

/**
* The score threshold for the file search. All values must be a floating point number between 0 and 1.
*/
@NotNull
@JsonProperty("score_threshold")
Double scoreThreshold;

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
public class FileSearchTool implements Tool {
final String type = "file_search";

/**
* The maximum number of results the file search tool should output. The default is 20 for gpt-4* models and 5 for gpt-3.5-turbo. This number should be between 1 and 50 inclusive.
*/
@JsonProperty("max_num_results")
Integer maxNumResults;

@JsonProperty("file_search")
FileSearch fileSearch;


}
2 changes: 1 addition & 1 deletion example/src/main/java/example/AssistantExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ static void fileSearchExample() throws UnsupportedEncodingException {
.name("file search assistant")
.instructions("你是一个中国传统音乐教授,负责根据用户的需求解答问题")
//add file search tool to assistant
.tools(Collections.singletonList(new FileSearchTool(1)))
.tools(Collections.singletonList(new FileSearchTool()))
.temperature(0D)
.build();
Assistant assistant = service.createAssistant(assistantRequest);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.theokanning.openai.service.assistants;

import com.theokanning.openai.ListSearchParameters;
import com.theokanning.openai.assistants.assistant.Assistant;
import com.theokanning.openai.assistants.assistant.AssistantRequest;
import com.theokanning.openai.assistants.assistant.FileSearchTool;
import com.theokanning.openai.assistants.assistant.*;
import com.theokanning.openai.assistants.message.MessageListSearchParameters;
import com.theokanning.openai.assistants.message.MessageRequest;
import com.theokanning.openai.assistants.run.Run;
Expand Down Expand Up @@ -49,7 +47,7 @@ void fileSearchExample(){
.name("file search assistant")
.instructions("你是一个中国传统音乐教授,负责根据用户的需求解答问题")
//add file search tool to assistant
.tools(Collections.singletonList(new FileSearchTool()))
.tools(Collections.singletonList(new FileSearchTool(new FileSearch(1,new FileSearchRankingOptions("auto", 0.5D)))))
.temperature(0.3D)
.build();
Assistant assistant = service.createAssistant(assistantRequest);
Expand Down