feat(core:inference): add ResponseFormat, ToolDefinition, ToolCallRequest; extend InferenceRequest with tools and responseFormat
This commit is contained in:
@@ -7,4 +7,5 @@ plugins {
|
||||
dependencies {
|
||||
implementation(project(":core:events"))
|
||||
implementation(project(":core:context"))
|
||||
implementation(project(":core:artifacts"))
|
||||
}
|
||||
@@ -9,6 +9,8 @@ sealed class FinishReason {
|
||||
@Serializable
|
||||
object Length : FinishReason()
|
||||
@Serializable
|
||||
object ToolCall : FinishReason()
|
||||
@Serializable
|
||||
object Timeout : FinishReason()
|
||||
@Serializable
|
||||
object Cancelled : FinishReason()
|
||||
|
||||
@@ -14,4 +14,6 @@ data class InferenceRequest(
|
||||
val contextPack: ContextPack,
|
||||
val generationConfig: GenerationConfig,
|
||||
val timeout: InferenceTimeout? = null,
|
||||
val responseFormat: ResponseFormat = ResponseFormat.Text,
|
||||
val tools: List<ToolDefinition> = emptyList(),
|
||||
)
|
||||
@@ -10,4 +10,5 @@ data class InferenceResponse(
|
||||
val finishReason: FinishReason,
|
||||
val tokensUsed: TokenUsage,
|
||||
val latencyMs: Long,
|
||||
val toolCalls: List<ToolCallRequest> = emptyList(),
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.correx.core.inference
|
||||
|
||||
import com.correx.core.artifacts.kind.JsonSchema
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
sealed interface ResponseFormat {
|
||||
@Serializable
|
||||
object Text : ResponseFormat
|
||||
|
||||
@Serializable
|
||||
data class Json(val schema: JsonSchema) : ResponseFormat
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.correx.core.inference
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ToolCallRequest(
|
||||
val id: String? = null,
|
||||
val type: String = "function",
|
||||
val function: ToolCallFunction,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class ToolCallFunction(
|
||||
val name: String,
|
||||
val arguments: String,
|
||||
)
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.correx.core.inference
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
@Serializable
|
||||
data class ToolDefinition(
|
||||
val type: String = "function",
|
||||
val function: ToolFunction,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class ToolFunction(
|
||||
val name: String,
|
||||
val description: String,
|
||||
val parameters: JsonObject,
|
||||
)
|
||||
Reference in New Issue
Block a user