Skip to content

Commit

Permalink
fix(runs): support for file search tool calls (#405)
Browse files Browse the repository at this point in the history
  • Loading branch information
averyaube authored Jan 31, 2025
1 parent 0581968 commit 4517677
Showing 1 changed file with 63 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public data class MessageCreation(
public data class ToolCallStepDetails(
/**
* An array of tool calls the run step was involved in.
* These can be associated with one of three types of tools:
* [ToolCallStep.CodeInterpreter], [ToolCallStep.RetrievalTool], or [ToolCallStep.FunctionTool].
* These can be associated with one of four types of tools:
* [ToolCallStep.CodeInterpreter], [ToolCallStep.RetrievalTool], [ToolCallStep.FunctionTool], or [ToolCallStep.FileSearchTool].
*/
@SerialName("tool_calls") public val toolCalls: List<ToolCallStep>? = null,
) : RunStepDetails
Expand Down Expand Up @@ -98,6 +98,20 @@ public sealed interface ToolCallStep {
*/
@SerialName("function") public val function: FunctionToolCallStep,
) : ToolCallStep

@BetaOpenAI
@Serializable
@SerialName("file_search")
public data class FileSearchTool(
/**
* The ID of the tool call object.
*/
@SerialName("id") public val id: ToolCallStepId,
/**
* The options and results of the file search.
*/
@SerialName("file_search") public val fileSearch: FileSearchToolCallStep,
) : ToolCallStep
}

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

@BetaOpenAI
@Serializable
public data class FileSearchToolCallStep(
/**
* The configured options for ranking.
*/
@SerialName("ranking_options") public val rankingOptions: FileSearchToolCallRankingOptions,

/**
* The returned results of the file search, ordered by score.
*/
@SerialName("results") public val results: List<FileSearchToolCallResult>,
)

@BetaOpenAI
@Serializable
public data class FileSearchToolCallRankingOptions(
/**
* The configured ranker.
*/
@SerialName("ranker") public val ranker: String,

/**
* The configured score threshold.
*/
@SerialName("score_threshold") public val scoreThreshold: Double,
)

@BetaOpenAI
@Serializable
public data class FileSearchToolCallResult(
/**
* The ID of the file object.
*/
@SerialName("file_id") public val fileId: FileId,

/**
* The original filename of the file object.
*/
@SerialName("file_name") public val fileName: String,

/**
* The score given to the provided result.
*/
@SerialName("score") public val score: Double,
)

@BetaOpenAI
@Serializable
public data class CodeInterpreterToolCall(
Expand Down

0 comments on commit 4517677

Please sign in to comment.