Skip to content

Commit 82cb704

Browse files
committed
feat: file search tool
1 parent 4f40921 commit 82cb704

File tree

6 files changed

+20
-9
lines changed

6 files changed

+20
-9
lines changed

api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>top.bella</groupId>
88
<artifactId>openai-java</artifactId>
9-
<version>0.23.57</version>
9+
<version>0.23.58</version>
1010
</parent>
1111
<packaging>jar</packaging>
1212
<artifactId>openai-api</artifactId>

api/src/main/java/com/theokanning/openai/assistants/assistant/Tool.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ class Retrieval implements Tool {
8888
@JsonInclude(JsonInclude.Include.NON_NULL)
8989
private Boolean inherit;
9090

91+
@JsonInclude(JsonInclude.Include.NON_NULL)
92+
@JsonProperty("file_ids")
93+
private List<String> fileIds;
94+
9195
public Retrieval() {
9296

9397
}
@@ -105,7 +109,9 @@ public String getType() {
105109
@Override
106110
public ToolDefinition definition() {
107111
com.theokanning.openai.response.tool.definition.FileSearchTool fileSearchTool = new com.theokanning.openai.response.tool.definition.FileSearchTool();
108-
fileSearchTool.setDefaultMetadata(defaultMetadata);
112+
fileSearchTool.setVectorStoreIds(fileIds);
113+
fileSearchTool.setRankingOptions(new com.theokanning.openai.response.tool.definition.FileSearchTool.RankingOptions(null, defaultMetadata.getScore()));
114+
fileSearchTool.setMaxNumResults(defaultMetadata.getTopK());
109115
return fileSearchTool;
110116
}
111117

api/src/main/java/com/theokanning/openai/response/tool/definition/FileSearchTool.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ public class FileSearchTool implements ToolDefinition {
2525
*/
2626
private String type = "file_search";
2727

28-
@JsonProperty("default_metadata")
29-
private Tool.DefaultMetadata defaultMetadata = new Tool.DefaultMetadata();
30-
3128
/**
3229
* Vector store IDs to search.
3330
*/
@@ -54,7 +51,15 @@ public class FileSearchTool implements ToolDefinition {
5451
@Override
5552
public Tool getRealTool() {
5653
Tool.Retrieval retrieval = new Tool.Retrieval();
57-
retrieval.setDefaultMetadata(defaultMetadata);
54+
Tool.DefaultMetadata metadata = new Tool.DefaultMetadata();
55+
if(maxNumResults != null) {
56+
metadata.setTopK(maxNumResults);
57+
}
58+
if(rankingOptions != null && rankingOptions.scoreThreshold != null) {
59+
metadata.setScore(rankingOptions.scoreThreshold);
60+
}
61+
retrieval.setFileIds(vectorStoreIds);
62+
retrieval.setDefaultMetadata(metadata);
5863
return retrieval;
5964
}
6065

client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>top.bella</groupId>
88
<artifactId>openai-java</artifactId>
9-
<version>0.23.57</version>
9+
<version>0.23.58</version>
1010
</parent>
1111
<packaging>jar</packaging>
1212

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>top.bella</groupId>
77
<artifactId>openai-java</artifactId>
8-
<version>0.23.57</version>
8+
<version>0.23.58</version>
99
<packaging>pom</packaging>
1010
<description>openai java 版本</description>
1111
<name>openai-java</name>

service/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>top.bella</groupId>
88
<artifactId>openai-java</artifactId>
9-
<version>0.23.57</version>
9+
<version>0.23.58</version>
1010
</parent>
1111
<packaging>jar</packaging>
1212

0 commit comments

Comments
 (0)