Skip to content
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

fix: support for file search tool calls #405

Merged
merged 2 commits into from
Jan 31, 2025
Merged
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
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