Skip to content

Commit 4517677

Browse files
authored
fix(runs): support for file search tool calls (#405)
1 parent 0581968 commit 4517677

File tree

1 file changed

+63
-2
lines changed

1 file changed

+63
-2
lines changed

openai-core/src/commonMain/kotlin/com.aallam.openai.api/run/RunStepDetails.kt

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public data class MessageCreation(
4747
public data class ToolCallStepDetails(
4848
/**
4949
* An array of tool calls the run step was involved in.
50-
* These can be associated with one of three types of tools:
51-
* [ToolCallStep.CodeInterpreter], [ToolCallStep.RetrievalTool], or [ToolCallStep.FunctionTool].
50+
* These can be associated with one of four types of tools:
51+
* [ToolCallStep.CodeInterpreter], [ToolCallStep.RetrievalTool], [ToolCallStep.FunctionTool], or [ToolCallStep.FileSearchTool].
5252
*/
5353
@SerialName("tool_calls") public val toolCalls: List<ToolCallStep>? = null,
5454
) : RunStepDetails
@@ -98,6 +98,20 @@ public sealed interface ToolCallStep {
9898
*/
9999
@SerialName("function") public val function: FunctionToolCallStep,
100100
) : ToolCallStep
101+
102+
@BetaOpenAI
103+
@Serializable
104+
@SerialName("file_search")
105+
public data class FileSearchTool(
106+
/**
107+
* The ID of the tool call object.
108+
*/
109+
@SerialName("id") public val id: ToolCallStepId,
110+
/**
111+
* The options and results of the file search.
112+
*/
113+
@SerialName("file_search") public val fileSearch: FileSearchToolCallStep,
114+
) : ToolCallStep
101115
}
102116

103117
@BetaOpenAI
@@ -119,6 +133,53 @@ public data class FunctionToolCallStep(
119133
@SerialName("output") public val output: String? = null,
120134
)
121135

136+
@BetaOpenAI
137+
@Serializable
138+
public data class FileSearchToolCallStep(
139+
/**
140+
* The configured options for ranking.
141+
*/
142+
@SerialName("ranking_options") public val rankingOptions: FileSearchToolCallRankingOptions,
143+
144+
/**
145+
* The returned results of the file search, ordered by score.
146+
*/
147+
@SerialName("results") public val results: List<FileSearchToolCallResult>,
148+
)
149+
150+
@BetaOpenAI
151+
@Serializable
152+
public data class FileSearchToolCallRankingOptions(
153+
/**
154+
* The configured ranker.
155+
*/
156+
@SerialName("ranker") public val ranker: String,
157+
158+
/**
159+
* The configured score threshold.
160+
*/
161+
@SerialName("score_threshold") public val scoreThreshold: Double,
162+
)
163+
164+
@BetaOpenAI
165+
@Serializable
166+
public data class FileSearchToolCallResult(
167+
/**
168+
* The ID of the file object.
169+
*/
170+
@SerialName("file_id") public val fileId: FileId,
171+
172+
/**
173+
* The original filename of the file object.
174+
*/
175+
@SerialName("file_name") public val fileName: String,
176+
177+
/**
178+
* The score given to the provided result.
179+
*/
180+
@SerialName("score") public val score: Double,
181+
)
182+
122183
@BetaOpenAI
123184
@Serializable
124185
public data class CodeInterpreterToolCall(

0 commit comments

Comments
 (0)