Skip to content

armgit / uzu

Public Imported from GitHub
0

A high-performance inference engine for AI models

Less insane encodings and reasoning effort (#773)

uuuvnbf276456cdc1
diff --git a/Cargo.lock b/Cargo.lock
index 30fab9acb..373f97c87 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -947,6 +947,7 @@ dependencies = [
"dirs",
"dotenvy",
"futures-util",
+ "hanashi",
"indexmap 2.14.0",
"indicatif",
"indoc",
@@ -7549,6 +7550,7 @@ dependencies = [
"fancy-regex 0.17.0",
"futures",
"futures-util",
+ "hanashi",
"indexmap 2.14.0",
"indicatif",
"inventory",
diff --git a/bindings/python/uzu/__init__.pyi b/bindings/python/uzu/__init__.pyi
index 5441554bd..5095c7b94 100644
--- a/bindings/python/uzu/__init__.pyi
+++ b/bindings/python/uzu/__init__.pyi
@@ -69,6 +69,7 @@ __all__ = [
"ReasoningEffort",
"Repository",
"SamplingMethod",
+ "SamplingParameters",
"SamplingPolicy",
"SamplingSeed",
"SettingKind",
@@ -302,12 +303,14 @@ class ChatModelCapabilities:
@property
def supports_disable_reasoning(self) -> builtins.bool: ...
@property
+ def reasoning_efforts(self) -> builtins.list[ReasoningEffort]: ...
+ @property
def supports_tools(self) -> builtins.bool: ...
@property
def supports_multiple_tool_calls(self) -> builtins.bool: ...
@property
def requires_tools(self) -> builtins.bool: ...
- def __new__(cls, supports_reasoning: builtins.bool, supports_disable_reasoning: builtins.bool, supports_tools: builtins.bool, supports_multiple_tool_calls: builtins.bool, requires_tools: builtins.bool) -> ChatModelCapabilities: ...
+ def __new__(cls, supports_reasoning: builtins.bool, supports_disable_reasoning: builtins.bool, reasoning_efforts: typing.Sequence[ReasoningEffort], supports_tools: builtins.bool, supports_multiple_tool_calls: builtins.bool, requires_tools: builtins.bool) -> ChatModelCapabilities: ...
@typing.final
class ChatReply:
@@ -438,6 +441,7 @@ class ChatSession:
def state(self) -> collections.abc.Awaitable[ChatSessionState]: ...
def messages(self) -> collections.abc.Awaitable[builtins.list[ChatMessage]]: ...
def supports_tool_calls(self) -> collections.abc.Awaitable[builtins.bool]: ...
+ def sampling_defaults(self) -> collections.abc.Awaitable[SamplingParameters | None]: ...
def reset(self) -> collections.abc.Awaitable[None]: ...
def reply(self, input: typing.Sequence[ChatMessage], config: ChatReplyConfig) -> collections.abc.Awaitable[builtins.list[ChatReply]]: ...
def reply_with_stream(self, input: typing.Sequence[ChatMessage], config: ChatReplyConfig) -> collections.abc.Awaitable[ChatSessionStream]: ...
@@ -844,7 +848,7 @@ class Model:
@property
def accessibility(self) -> ModelAccessibility: ...
@property
- def encodings(self) -> builtins.list[Value]: ...
+ def encoding(self) -> typing.Optional[Value]: ...
@property
def name(self) -> builtins.str: ...
@property
@@ -875,9 +879,9 @@ class Model:
def is_translation_capable(self) -> builtins.bool: ...
@property
def is_speculation_capable(self) -> builtins.bool: ...
- def __new__(cls, identifier: builtins.str, registry: ModelRegistry, backends: typing.Sequence[ModelBackend], family: typing.Optional[ModelFamily], properties: typing.Optional[ModelProperties], quantization: typing.Optional[ModelQuantization], specializations: typing.Sequence[ModelSpecialization], accessibility: ModelAccessibility, encodings: typing.Sequence[Value]) -> Model: ...
+ def __new__(cls, identifier: builtins.str, registry: ModelRegistry, backends: typing.Sequence[ModelBackend], family: typing.Optional[ModelFamily], properties: typing.Optional[ModelProperties], quantization: typing.Optional[ModelQuantization], specializations: typing.Sequence[ModelSpecialization], accessibility: ModelAccessibility, encoding: typing.Optional[Value]) -> Model: ...
@staticmethod
- def external(identifier: builtins.str, registry_identifier: builtins.str, registry_name: builtins.str, backend_identifier: builtins.str, backend_name: builtins.str, backend_version: builtins.str, specializations: typing.Sequence[ModelSpecialization], accessibility: ModelAccessibility, encodings: typing.Sequence[Value]) -> Model: ...
+ def external(identifier: builtins.str, registry_identifier: builtins.str, registry_name: builtins.str, backend_identifier: builtins.str, backend_name: builtins.str, backend_version: builtins.str, specializations: typing.Sequence[ModelSpecialization], accessibility: ModelAccessibility, encoding: typing.Optional[Value]) -> Model: ...
class ModelAccessibility:
@typing.final
@@ -1089,6 +1093,22 @@ class SamplingMethod:
...
+class SamplingParameters:
+ @property
+ def temperature(self) -> typing.Optional[builtins.float]: ...
+ @property
+ def top_k(self) -> typing.Optional[builtins.int]: ...
+ @property
+ def top_p(self) -> typing.Optional[builtins.float]: ...
+ @property
+ def min_p(self) -> typing.Optional[builtins.float]: ...
+ @property
+ def repetition_penalty(self) -> typing.Optional[builtins.float]: ...
+ @property
+ def suffix_repetition_length(self) -> typing.Optional[builtins.int]: ...
+ def __new__(cls, temperature: typing.Optional[builtins.float], top_k: typing.Optional[builtins.int], top_p: typing.Optional[builtins.float], min_p: typing.Optional[builtins.float], repetition_penalty: typing.Optional[builtins.float], suffix_repetition_length: typing.Optional[builtins.int]) -> SamplingParameters: ...
+
class SamplingPolicy:
@typing.final
class Default(SamplingPolicy):
@@ -1326,6 +1346,7 @@ class ReasoningEffort(enum.Enum):
Low = ...
Medium = ...
High = ...
+ XHigh = ...
@typing.final
class SettingKind(enum.Enum):
diff --git a/bindings/swift/Sources/Uzu/Generated/Extensions.swift b/bindings/swift/Sources/Uzu/Generated/Extensions.swift
index ea2d3767d..ad030d6ae 100644
--- a/bindings/swift/Sources/Uzu/Generated/Extensions.swift
+++ b/bindings/swift/Sources/Uzu/Generated/Extensions.swift
@@ -91,8 +91,8 @@ extension Metadata {
}
extension Model {
- public static func external(identifier: String, registryIdentifier: String, registryName: String, backendIdentifier: String, backendName: String, backendVersion: String, specializations: [ModelSpecialization], accessibility: ModelAccessibility, encodings: [Value]) -> Model {
- modelExternal(identifier: identifier, registryIdentifier: registryIdentifier, registryName: registryName, backendIdentifier: backendIdentifier, backendName: backendName, backendVersion: backendVersion, specializations: specializations, accessibility: accessibility, encodings: encodings)
+ public static func external(identifier: String, registryIdentifier: String, registryName: String, backendIdentifier: String, backendName: String, backendVersion: String, specializations: [ModelSpecialization], accessibility: ModelAccessibility, encoding: Value?) -> Model {
+ modelExternal(identifier: identifier, registryIdentifier: registryIdentifier, registryName: registryName, backendIdentifier: backendIdentifier, backendName: backendName, backendVersion: backendVersion, specializations: specializations, accessibility: accessibility, encoding: encoding)
}
}
diff --git a/bindings/swift/Sources/Uzu/Generated/uzu/nagare.swift b/bindings/swift/Sources/Uzu/Generated/uzu/nagare.swift
index d31d20e72..37afdf08a 100644
--- a/bindings/swift/Sources/Uzu/Generated/uzu/nagare.swift
+++ b/bindings/swift/Sources/Uzu/Generated/uzu/nagare.swift
@@ -646,6 +646,8 @@ public protocol ChatSessionProtocol: AnyObject, Sendable {
func reset() async throws
+ func samplingDefaults() async -> SamplingParameters?
+
func state() async -> ChatSessionState
func supportsToolCalls() async -> Bool
@@ -808,6 +810,24 @@ open func reset()async throws {
)
}
+open func samplingDefaults()async -> SamplingParameters? {
+ return
+ try! await uniffiRustCallAsync(
+ rustFutureFunc: {
+ uniffi_nagare_fn_method_chatsession_sampling_defaults(
+ self.uniffiCloneHandle()
+
+ )
+ },
+ pollFunc: ffi_nagare_rust_future_poll_rust_buffer,
+ completeFunc: ffi_nagare_rust_future_complete_rust_buffer,
+ freeFunc: ffi_nagare_rust_future_free_rust_buffer,
+ liftFunc: FfiConverterOptionTypeSamplingParameters.lift,
+ errorHandler: nil
+
+ )
+}
+
open func state()async -> ChatSessionState {
return
try! await uniffiRustCallAsync(
@@ -2462,6 +2482,30 @@ public func FfiConverterCallbackInterfaceForeignToolHandler_lower(_ v: ForeignTo
return FfiConverterCallbackInterfaceForeignToolHandler.lower(v)
}
+#if swift(>=5.8)
+@_documentation(visibility: private)
+#endif
+fileprivate struct FfiConverterOptionTypeSamplingParameters: FfiConverterRustBuffer {
+ typealias SwiftType = SamplingParameters?
+
+ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
+ guard let value = value else {
+ writeInt(&buf, Int8(0))
+ return
+ }
+ writeInt(&buf, Int8(1))
+ FfiConverterTypeSamplingParameters.write(value, into: &buf)
+ }
+
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
+ switch try readInt(&buf) as Int8 {
+ case 0: return nil
+ case 1: return try FfiConverterTypeSamplingParameters.read(from: &buf)
+ default: throw UniffiInternalError.unexpectedOptionalTag
+ }
+ }
+}
+
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
@@ -2781,6 +2825,9 @@ private let initializationResult: InitializationResult = {
if (uniffi_nagare_checksum_method_chatsession_reset() != 1317) {
return InitializationResult.apiChecksumMismatch
}
+ if (uniffi_nagare_checksum_method_chatsession_sampling_defaults() != 47931) {
+ return InitializationResult.apiChecksumMismatch
+ }
if (uniffi_nagare_checksum_method_chatsession_state() != 61854) {
return InitializationResult.apiChecksumMismatch
}
diff --git a/bindings/swift/Sources/Uzu/Generated/uzu/shoji.swift b/bindings/swift/Sources/Uzu/Generated/uzu/shoji.swift
index c9f7e5f2e..78e42a92f 100644
--- a/bindings/swift/Sources/Uzu/Generated/uzu/shoji.swift
+++ b/bindings/swift/Sources/Uzu/Generated/uzu/shoji.swift
@@ -941,15 +941,17 @@ public func FfiConverterTypeChatMessageMetadata_lower(_ value: ChatMessageMetada
public struct ChatModelCapabilities: Equatable, Hashable, Codable {
public var supportsReasoning: Bool
public var supportsDisableReasoning: Bool
+ public var reasoningEfforts: [ReasoningEffort]
public var supportsTools: Bool
public var supportsMultipleToolCalls: Bool
public var requiresTools: Bool
// Default memberwise initializers are never public by default, so we
// declare one manually.
- public init(supportsReasoning: Bool, supportsDisableReasoning: Bool, supportsTools: Bool, supportsMultipleToolCalls: Bool, requiresTools: Bool) {
+ public init(supportsReasoning: Bool, supportsDisableReasoning: Bool, reasoningEfforts: [ReasoningEffort], supportsTools: Bool, supportsMultipleToolCalls: Bool, requiresTools: Bool) {
self.supportsReasoning = supportsReasoning
self.supportsDisableReasoning = supportsDisableReasoning
+ self.reasoningEfforts = reasoningEfforts
self.supportsTools = supportsTools
self.supportsMultipleToolCalls = supportsMultipleToolCalls
self.requiresTools = requiresTools
@@ -973,6 +975,7 @@ public struct FfiConverterTypeChatModelCapabilities: FfiConverterRustBuffer {
try ChatModelCapabilities(
supportsReasoning: FfiConverterBool.read(from: &buf),
supportsDisableReasoning: FfiConverterBool.read(from: &buf),
+ reasoningEfforts: FfiConverterSequenceTypeReasoningEffort.read(from: &buf),
supportsTools: FfiConverterBool.read(from: &buf),
supportsMultipleToolCalls: FfiConverterBool.read(from: &buf),
requiresTools: FfiConverterBool.read(from: &buf)
@@ -982,6 +985,7 @@ public struct FfiConverterTypeChatModelCapabilities: FfiConverterRustBuffer {
public static func write(_ value: ChatModelCapabilities, into buf: inout [UInt8]) {
FfiConverterBool.write(value.supportsReasoning, into: &buf)
FfiConverterBool.write(value.supportsDisableReasoning, into: &buf)
+ FfiConverterSequenceTypeReasoningEffort.write(value.reasoningEfforts, into: &buf)
FfiConverterBool.write(value.supportsTools, into: &buf)
FfiConverterBool.write(value.supportsMultipleToolCalls, into: &buf)
FfiConverterBool.write(value.requiresTools, into: &buf)
@@ -2047,11 +2051,11 @@ public struct Model: Equatable, Hashable, Codable {
public var quantization: ModelQuantization?
public var specializations: [ModelSpecialization]
public var accessibility: ModelAccessibility
- public var encodings: [Value]
+ public var encoding: Value?
// Default memberwise initializers are never public by default, so we
// declare one manually.
- public init(identifier: String, registry: ModelRegistry, backends: [ModelBackend], family: ModelFamily?, properties: ModelProperties?, quantization: ModelQuantization?, specializations: [ModelSpecialization], accessibility: ModelAccessibility, encodings: [Value]) {
+ public init(identifier: String, registry: ModelRegistry, backends: [ModelBackend], family: ModelFamily?, properties: ModelProperties?, quantization: ModelQuantization?, specializations: [ModelSpecialization], accessibility: ModelAccessibility, encoding: Value?) {
self.identifier = identifier
self.registry = registry
self.backends = backends
@@ -2060,7 +2064,7 @@ public struct Model: Equatable, Hashable, Codable {
self.quantization = quantization
self.specializations = specializations
self.accessibility = accessibility
- self.encodings = encodings
+ self.encoding = encoding
}
@@ -2207,7 +2211,7 @@ public struct FfiConverterTypeModel: FfiConverterRustBuffer {
quantization: FfiConverterOptionTypeModelQuantization.read(from: &buf),
specializations: FfiConverterSequenceTypeModelSpecialization.read(from: &buf),
accessibility: FfiConverterTypeModelAccessibility.read(from: &buf),
- encodings: FfiConverterSequenceTypeValue.read(from: &buf)
+ encoding: FfiConverterOptionTypeValue.read(from: &buf)
)
}
@@ -2220,7 +2224,7 @@ public struct FfiConverterTypeModel: FfiConverterRustBuffer {
FfiConverterOptionTypeModelQuantization.write(value.quantization, into: &buf)
FfiConverterSequenceTypeModelSpecialization.write(value.specializations, into: &buf)
FfiConverterTypeModelAccessibility.write(value.accessibility, into: &buf)
- FfiConverterSequenceTypeValue.write(value.encodings, into: &buf)
+ FfiConverterOptionTypeValue.write(value.encoding, into: &buf)
}
}
@@ -2792,6 +2796,76 @@ public func FfiConverterTypeRepository_lower(_ value: Repository) -> RustBuffer
}
+public struct SamplingParameters: Equatable, Hashable, Codable {
+ public var temperature: Double?
+ public var topK: Int64?
+ public var topP: Double?
+ public var minP: Double?
+ public var repetitionPenalty: Double?
+ public var suffixRepetitionLength: Int64?
+
+ // Default memberwise initializers are never public by default, so we
+ // declare one manually.
+ public init(temperature: Double?, topK: Int64?, topP: Double?, minP: Double?, repetitionPenalty: Double?, suffixRepetitionLength: Int64?) {
+ self.temperature = temperature
+ self.topK = topK
+ self.topP = topP
+ self.minP = minP
+ self.repetitionPenalty = repetitionPenalty
+ self.suffixRepetitionLength = suffixRepetitionLength
+ }
+
+
+
+
+}
+
+#if compiler(>=6)
+extension SamplingParameters: Sendable {}
+#endif
+
+#if swift(>=5.8)
+@_documentation(visibility: private)
+#endif
+public struct FfiConverterTypeSamplingParameters: FfiConverterRustBuffer {
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SamplingParameters {
+ return
+ try SamplingParameters(
+ temperature: FfiConverterOptionDouble.read(from: &buf),
+ topK: FfiConverterOptionInt64.read(from: &buf),
+ topP: FfiConverterOptionDouble.read(from: &buf),
+ minP: FfiConverterOptionDouble.read(from: &buf),
+ repetitionPenalty: FfiConverterOptionDouble.read(from: &buf),
+ suffixRepetitionLength: FfiConverterOptionInt64.read(from: &buf)
+ )
+ }
+
+ public static func write(_ value: SamplingParameters, into buf: inout [UInt8]) {
+ FfiConverterOptionDouble.write(value.temperature, into: &buf)
+ FfiConverterOptionInt64.write(value.topK, into: &buf)
+ FfiConverterOptionDouble.write(value.topP, into: &buf)
+ FfiConverterOptionDouble.write(value.minP, into: &buf)
+ FfiConverterOptionDouble.write(value.repetitionPenalty, into: &buf)
+ FfiConverterOptionInt64.write(value.suffixRepetitionLength, into: &buf)
+ }
+}
+
+
+#if swift(>=5.8)
+@_documentation(visibility: private)
+#endif
+public func FfiConverterTypeSamplingParameters_lift(_ buf: RustBuffer) throws -> SamplingParameters {
+ return try FfiConverterTypeSamplingParameters.lift(buf)
+}
+
+#if swift(>=5.8)
+@_documentation(visibility: private)
+#endif
+public func FfiConverterTypeSamplingParameters_lower(_ value: SamplingParameters) -> RustBuffer {
+ return FfiConverterTypeSamplingParameters.lower(value)
+}
+
+
public struct TextToSpeechOutput: Equatable, Hashable, Codable {
public var pcmBatch: PcmBatch
public var stats: TextToSpeechStats
@@ -4548,6 +4622,7 @@ public enum ReasoningEffort: Equatable, Hashable, Codable {
case low
case medium
case high
+ case xHigh
@@ -4579,6 +4654,8 @@ public struct FfiConverterTypeReasoningEffort: FfiConverterRustBuffer {
case 5: return .high
+ case 6: return .xHigh
+
default: throw UniffiInternalError.unexpectedEnumCase
}
}
@@ -4606,6 +4683,10 @@ public struct FfiConverterTypeReasoningEffort: FfiConverterRustBuffer {
case .high:
writeInt(&buf, Int32(5))
+
+ case .xHigh:
+ writeInt(&buf, Int32(6))
+
}
}
}
@@ -5565,23 +5646,23 @@ fileprivate struct FfiConverterSequenceTypeToolNamespace: FfiConverterRustBuffer
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
-fileprivate struct FfiConverterSequenceTypeValue: FfiConverterRustBuffer {
- typealias SwiftType = [Value]
+fileprivate struct FfiConverterSequenceTypeChatContentBlock: FfiConverterRustBuffer {
+ typealias SwiftType = [ChatContentBlock]
- public static func write(_ value: [Value], into buf: inout [UInt8]) {
+ public static func write(_ value: [ChatContentBlock], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
- FfiConverterTypeValue.write(item, into: &buf)
+ FfiConverterTypeChatContentBlock.write(item, into: &buf)
}
}
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Value] {
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ChatContentBlock] {
let len: Int32 = try readInt(&buf)
- var seq = [Value]()
+ var seq = [ChatContentBlock]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
- seq.append(try FfiConverterTypeValue.read(from: &buf))
+ seq.append(try FfiConverterTypeChatContentBlock.read(from: &buf))
}
return seq
}
@@ -5590,23 +5671,23 @@ fileprivate struct FfiConverterSequenceTypeValue: FfiConverterRustBuffer {
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
-fileprivate struct FfiConverterSequenceTypeChatContentBlock: FfiConverterRustBuffer {
- typealias SwiftType = [ChatContentBlock]
+fileprivate struct FfiConverterSequenceTypeModelSpecialization: FfiConverterRustBuffer {
+ typealias SwiftType = [ModelSpecialization]
- public static func write(_ value: [ChatContentBlock], into buf: inout [UInt8]) {
+ public static func write(_ value: [ModelSpecialization], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
- FfiConverterTypeChatContentBlock.write(item, into: &buf)
+ FfiConverterTypeModelSpecialization.write(item, into: &buf)
}
}
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ChatContentBlock] {
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ModelSpecialization] {
let len: Int32 = try readInt(&buf)
- var seq = [ChatContentBlock]()
+ var seq = [ModelSpecialization]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
- seq.append(try FfiConverterTypeChatContentBlock.read(from: &buf))
+ seq.append(try FfiConverterTypeModelSpecialization.read(from: &buf))
}
return seq
}
@@ -5615,23 +5696,23 @@ fileprivate struct FfiConverterSequenceTypeChatContentBlock: FfiConverterRustBuf
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
-fileprivate struct FfiConverterSequenceTypeModelSpecialization: FfiConverterRustBuffer {
- typealias SwiftType = [ModelSpecialization]
+fileprivate struct FfiConverterSequenceTypeReasoningEffort: FfiConverterRustBuffer {
+ typealias SwiftType = [ReasoningEffort]
- public static func write(_ value: [ModelSpecialization], into buf: inout [UInt8]) {
+ public static func write(_ value: [ReasoningEffort], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
- FfiConverterTypeModelSpecialization.write(item, into: &buf)
+ FfiConverterTypeReasoningEffort.write(item, into: &buf)
}
}
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ModelSpecialization] {
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ReasoningEffort] {
let len: Int32 = try readInt(&buf)
- var seq = [ModelSpecialization]()
+ var seq = [ReasoningEffort]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
- seq.append(try FfiConverterTypeModelSpecialization.read(from: &buf))
+ seq.append(try FfiConverterTypeReasoningEffort.read(from: &buf))
}
return seq
}
@@ -5726,7 +5807,7 @@ public func metadataExternal(name: String) -> Metadata {
)
})
}
-public func modelExternal(identifier: String, registryIdentifier: String, registryName: String, backendIdentifier: String, backendName: String, backendVersion: String, specializations: [ModelSpecialization], accessibility: ModelAccessibility, encodings: [Value]) -> Model {
+public func modelExternal(identifier: String, registryIdentifier: String, registryName: String, backendIdentifier: String, backendName: String, backendVersion: String, specializations: [ModelSpecialization], accessibility: ModelAccessibility, encoding: Value?) -> Model {
return try! FfiConverterTypeModel_lift(try! rustCall() {
uniffi_shoji_fn_func_model_external(
FfiConverterString.lower(identifier),
@@ -5737,7 +5818,7 @@ public func modelExternal(identifier: String, registryIdentifier: String, regist
FfiConverterString.lower(backendVersion),
FfiConverterSequenceTypeModelSpecialization.lower(specializations),
FfiConverterTypeModelAccessibility_lower(accessibility),
- FfiConverterSequenceTypeValue.lower(encodings),$0
+ FfiConverterOptionTypeValue.lower(encoding),$0
)
})
}
@@ -5826,7 +5907,7 @@ private let initializationResult: InitializationResult = {
if (uniffi_shoji_checksum_func_metadata_external() != 17881) {
return InitializationResult.apiChecksumMismatch
}
- if (uniffi_shoji_checksum_func_model_external() != 25859) {
+ if (uniffi_shoji_checksum_func_model_external() != 45448) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_shoji_checksum_func_chat_config_create() != 48867) {
diff --git a/bindings/typescript/src/napi/index.d.mts b/bindings/typescript/src/napi/index.d.mts
index 92f9c1556..1dfb65555 100644
--- a/bindings/typescript/src/napi/index.d.mts
+++ b/bindings/typescript/src/napi/index.d.mts
@@ -15,6 +15,7 @@ export declare class ChatSession {
get state(): Promise<ChatSessionState>
get messages(): Promise<Array<ChatMessage>>
get supportsToolCalls(): Promise<boolean>
+ get samplingDefaults(): Promise<SamplingParameters | null>
reset(): Promise<void>
reply(input: Array<ChatMessage>, config: ChatReplyConfig): Promise<Array<ChatReply>>
replyWithStream(input: Array<ChatMessage>, config: ChatReplyConfig): Promise<ChatSessionStream>
@@ -255,10 +256,11 @@ export declare class ChatMessage {
export declare class ChatModelCapabilities {
supportsReasoning: boolean
supportsDisableReasoning: boolean
+ reasoningEfforts: Array<ReasoningEffort>
supportsTools: boolean
supportsMultipleToolCalls: boolean
requiresTools: boolean
- constructor(supportsReasoning: boolean, supportsDisableReasoning: boolean, supportsTools: boolean, supportsMultipleToolCalls: boolean, requiresTools: boolean)
+ constructor(supportsReasoning: boolean, supportsDisableReasoning: boolean, reasoningEfforts: Array<ReasoningEffort>, supportsTools: boolean, supportsMultipleToolCalls: boolean, requiresTools: boolean)
}
export declare class ChatReply {
@@ -470,8 +472,8 @@ export declare class Model {
quantization?: ModelQuantization
specializations: Array<ModelSpecialization>
accessibility: ModelAccessibility
- encodings: Array<any>
- constructor(identifier: string, registry: ModelRegistry, backends: Array<ModelBackend>, family?: ModelFamily, properties?: ModelProperties, quantization?: ModelQuantization, specializations: Array<ModelSpecialization>, accessibility: ModelAccessibility, encodings: Array<any>)
+ encoding?: any
+ constructor(identifier: string, registry: ModelRegistry, backends: Array<ModelBackend>, family?: ModelFamily, properties?: ModelProperties, quantization?: ModelQuantization, specializations: Array<ModelSpecialization>, accessibility: ModelAccessibility, encoding?: any)
get name(): string
get isLocal(): boolean
get isRemote(): boolean
@@ -483,7 +485,7 @@ export declare class Model {
get referenceName(): string | null
get checkpointVersion(): string | null
- static external(identifier: string, registryIdentifier: string, registryName: string, backendIdentifier: string, backendName: string, backendVersion: string, specializations: Array<ModelSpecialization>, accessibility: ModelAccessibility, encodings: Array<any>): Model
+ static external(identifier: string, registryIdentifier: string, registryName: string, backendIdentifier: string, backendName: string, backendVersion: string, specializations: Array<ModelSpecialization>, accessibility: ModelAccessibility, encoding?: any | undefined | null): Model
get isChatCapable(): boolean
get isClassificationCapable(): boolean
get isTextToSpeechCapable(): boolean
@@ -627,6 +629,16 @@ export declare class SamplingMethodStochastic {
constructor(temperature?: number, topK?: number, topP?: number, minP?: number, repetitionPenalty?: number, suffixRepetitionLength?: number)
}
+export declare class SamplingParameters {
+ temperature?: number
+ topK?: number
+ topP?: number
+ minP?: number
+ repetitionPenalty?: number
+ suffixRepetitionLength?: number
+ constructor(temperature?: number, topK?: number, topP?: number, minP?: number, repetitionPenalty?: number, suffixRepetitionLength?: number)
+}
+
export declare class SamplingPolicyCustom {
method: SamplingMethod
constructor(method: SamplingMethod)
@@ -797,7 +809,8 @@ export declare const enum ReasoningEffort {
Default = 'Default',
Low = 'Low',
Medium = 'Medium',
- High = 'High'
+ High = 'High',
+ XHigh = 'XHigh'
}
export type SamplingMethod =
diff --git a/bindings/typescript/src/napi/index.d.ts b/bindings/typescript/src/napi/index.d.ts
index 92f9c1556..1dfb65555 100644
--- a/bindings/typescript/src/napi/index.d.ts
+++ b/bindings/typescript/src/napi/index.d.ts
@@ -15,6 +15,7 @@ export declare class ChatSession {
get state(): Promise<ChatSessionState>
get messages(): Promise<Array<ChatMessage>>
get supportsToolCalls(): Promise<boolean>
+ get samplingDefaults(): Promise<SamplingParameters | null>
reset(): Promise<void>
reply(input: Array<ChatMessage>, config: ChatReplyConfig): Promise<Array<ChatReply>>
replyWithStream(input: Array<ChatMessage>, config: ChatReplyConfig): Promise<ChatSessionStream>
@@ -255,10 +256,11 @@ export declare class ChatMessage {
export declare class ChatModelCapabilities {
supportsReasoning: boolean
supportsDisableReasoning: boolean
+ reasoningEfforts: Array<ReasoningEffort>
supportsTools: boolean
supportsMultipleToolCalls: boolean
requiresTools: boolean
- constructor(supportsReasoning: boolean, supportsDisableReasoning: boolean, supportsTools: boolean, supportsMultipleToolCalls: boolean, requiresTools: boolean)
+ constructor(supportsReasoning: boolean, supportsDisableReasoning: boolean, reasoningEfforts: Array<ReasoningEffort>, supportsTools: boolean, supportsMultipleToolCalls: boolean, requiresTools: boolean)
}
export declare class ChatReply {
@@ -470,8 +472,8 @@ export declare class Model {
quantization?: ModelQuantization
specializations: Array<ModelSpecialization>
accessibility: ModelAccessibility
- encodings: Array<any>
- constructor(identifier: string, registry: ModelRegistry, backends: Array<ModelBackend>, family?: ModelFamily, properties?: ModelProperties, quantization?: ModelQuantization, specializations: Array<ModelSpecialization>, accessibility: ModelAccessibility, encodings: Array<any>)
+ encoding?: any
+ constructor(identifier: string, registry: ModelRegistry, backends: Array<ModelBackend>, family?: ModelFamily, properties?: ModelProperties, quantization?: ModelQuantization, specializations: Array<ModelSpecialization>, accessibility: ModelAccessibility, encoding?: any)
get name(): string
get isLocal(): boolean
get isRemote(): boolean
@@ -483,7 +485,7 @@ export declare class Model {
get referenceName(): string | null
get checkpointVersion(): string | null
- static external(identifier: string, registryIdentifier: string, registryName: string, backendIdentifier: string, backendName: string, backendVersion: string, specializations: Array<ModelSpecialization>, accessibility: ModelAccessibility, encodings: Array<any>): Model
+ static external(identifier: string, registryIdentifier: string, registryName: string, backendIdentifier: string, backendName: string, backendVersion: string, specializations: Array<ModelSpecialization>, accessibility: ModelAccessibility, encoding?: any | undefined | null): Model
get isChatCapable(): boolean
get isClassificationCapable(): boolean
get isTextToSpeechCapable(): boolean
@@ -627,6 +629,16 @@ export declare class SamplingMethodStochastic {
constructor(temperature?: number, topK?: number, topP?: number, minP?: number, repetitionPenalty?: number, suffixRepetitionLength?: number)
}
+export declare class SamplingParameters {
+ temperature?: number
+ topK?: number
+ topP?: number
+ minP?: number
+ repetitionPenalty?: number
+ suffixRepetitionLength?: number
+ constructor(temperature?: number, topK?: number, topP?: number, minP?: number, repetitionPenalty?: number, suffixRepetitionLength?: number)
+}
+
export declare class SamplingPolicyCustom {
method: SamplingMethod
constructor(method: SamplingMethod)
@@ -797,7 +809,8 @@ export declare const enum ReasoningEffort {
Default = 'Default',
Low = 'Low',
Medium = 'Medium',
- High = 'High'
+ High = 'High',
+ XHigh = 'XHigh'
}
export type SamplingMethod =
diff --git a/bindings/typescript/src/napi/index.js b/bindings/typescript/src/napi/index.js
index 20ea8cf7a..785c41601 100644
--- a/bindings/typescript/src/napi/index.js
+++ b/bindings/typescript/src/napi/index.js
@@ -590,6 +590,7 @@ module.exports.PcmBatch = nativeBinding.PcmBatch
module.exports.Repository = nativeBinding.Repository
module.exports.SamplingMethodGreedy = nativeBinding.SamplingMethodGreedy
module.exports.SamplingMethodStochastic = nativeBinding.SamplingMethodStochastic
+module.exports.SamplingParameters = nativeBinding.SamplingParameters
module.exports.SamplingPolicyCustom = nativeBinding.SamplingPolicyCustom
module.exports.SamplingPolicyDefault = nativeBinding.SamplingPolicyDefault
module.exports.SamplingSeedCustom = nativeBinding.SamplingSeedCustom
diff --git a/bindings/typescript/src/napi/index.mjs b/bindings/typescript/src/napi/index.mjs
index 13c7f20a7..fead56beb 100644
--- a/bindings/typescript/src/napi/index.mjs
+++ b/bindings/typescript/src/napi/index.mjs
@@ -87,6 +87,7 @@ export const PcmBatch = cjs.PcmBatch;
export const Repository = cjs.Repository;
export const SamplingMethodGreedy = cjs.SamplingMethodGreedy;
export const SamplingMethodStochastic = cjs.SamplingMethodStochastic;
+export const SamplingParameters = cjs.SamplingParameters;
export const SamplingPolicyCustom = cjs.SamplingPolicyCustom;
export const SamplingPolicyDefault = cjs.SamplingPolicyDefault;
export const SamplingSeedCustom = cjs.SamplingSeedCustom;
diff --git a/crates/legacy/backend-remote/src/openai/bridging/reasoning_effort.rs b/crates/legacy/backend-remote/src/openai/bridging/reasoning_effort.rs
index 535672429..27b589071 100644
--- a/crates/legacy/backend-remote/src/openai/bridging/reasoning_effort.rs
+++ b/crates/legacy/backend-remote/src/openai/bridging/reasoning_effort.rs
@@ -8,5 +8,6 @@ pub fn build(effort: ReasoningEffort) -> OpenAIReasoningEffort {
ReasoningEffort::Low => OpenAIReasoningEffort::Low,
ReasoningEffort::Medium => OpenAIReasoningEffort::Medium,
ReasoningEffort::High => OpenAIReasoningEffort::High,
+ ReasoningEffort::XHigh => OpenAIReasoningEffort::Xhigh,
}
}
diff --git a/crates/legacy/cli/Cargo.toml b/crates/legacy/cli/Cargo.toml
index 81c96858c..cd9a8daf9 100644
--- a/crates/legacy/cli/Cargo.toml
+++ b/crates/legacy/cli/Cargo.toml
@@ -29,6 +29,7 @@ crossterm.workspace = true
dirs.workspace = true
dotenvy.workspace = true
futures-util.workspace = true
+hanashi.workspace = true
indexmap.workspace = true
indicatif.workspace = true
indoc.workspace = true
diff --git a/crates/legacy/cli/src/common/mod.rs b/crates/legacy/cli/src/common/mod.rs
index b82352bf4..9602a9e2c 100644
--- a/crates/legacy/cli/src/common/mod.rs
+++ b/crates/legacy/cli/src/common/mod.rs
@@ -1 +1 @@
-pub mod model_capabilities;
+pub mod thinking;
diff --git a/crates/legacy/cli/src/common/model_capabilities.rs b/crates/legacy/cli/src/common/model_capabilities.rs
deleted file mode 100644
index 5d6346fdf..000000000
--- a/crates/legacy/cli/src/common/model_capabilities.rs
+++ /dev/null
@@ -1,255 +0,0 @@
-use std::path::Path;
-
-use serde::{Deserialize, Serialize};
-use serde_json::Value;
-use shoji::types::{basic::ReasoningEffort, model::Model};
-use uzu::engine::Engine;
-
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
-#[serde(default)]
-pub struct ThinkingPreference {
- pub level: ReasoningEffort,
- pub enabled: bool,
-}
-
-impl Default for ThinkingPreference {
- fn default() -> Self {
- Self {
- level: ReasoningEffort::Default,
- enabled: true,
- }
- }
-}
-
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
-pub enum ThinkingSupport {
- Levels(ReasoningEffort),
- Toggle(bool),
- AlwaysOn,
- #[default]
- Unsupported,
-}
-
-impl ThinkingSupport {
- pub fn is_adjustable(self) -> bool {
- matches!(self, Self::Levels(_) | Self::Toggle(_))
- }
-
- pub fn with_preference(
- self,
- preference: &ThinkingPreference,
- ) -> Self {
- match self {
- Self::Levels(_) => Self::Levels(preference.level),
- Self::Toggle(_) => Self::Toggle(preference.enabled),
- other => other,
- }
- }
-
- /// Resolve a requested effort against what this model can actually do.
- /// `Ok(Some(effort))` — emit this effort; `Ok(None)` — the request is already
- /// satisfied by the model's fixed behavior; `Err` — the requested thinking
- /// state cannot be produced, so the caller must reject the request rather
- /// than silently ignore it.
- pub fn fulfill_requested_effort(
- self,
- effort: ReasoningEffort,
- ) -> Result<Option<ReasoningEffort>, String> {
- match self {
- // A levels model applies the exact effort; default needs no explicit message.
- Self::Levels(_) => Ok(if effort == ReasoningEffort::Default {
- None
- } else {
- Some(effort)
- }),
- // A toggle model honors the on/off state; effort levels collapse to on.
- Self::Toggle(_) => Ok(Some(if effort == ReasoningEffort::Disabled {
- ReasoningEffort::Disabled
- } else {
- ReasoningEffort::Default
- })),
- Self::AlwaysOn => {
- if effort == ReasoningEffort::Disabled {
- Err("model always reasons; reasoning cannot be disabled".to_string())
- } else {
- Ok(None)
- }
- },
- Self::Unsupported => {
- if effort == ReasoningEffort::Disabled {
- Ok(None)
- } else {
- Err("model does not support reasoning".to_string())
- }
- },
- }
- }
-
- pub fn reasoning_effort(self) -> Option<ReasoningEffort> {
- match self {
- Self::Levels(ReasoningEffort::Default) => None,
- Self::Levels(effort) => Some(effort),
- Self::Toggle(true) => Some(ReasoningEffort::Default),
- Self::Toggle(false) => Some(ReasoningEffort::Disabled),
- Self::AlwaysOn | Self::Unsupported => None,
- }
- }
-}
-
-#[derive(Debug, Clone, Copy, PartialEq, Default)]
-pub struct ModelSamplingDefaults {
- pub temperature: Option<f64>,
- pub top_k: Option<i64>,
- pub top_p: Option<f64>,
- pub min_p: Option<f64>,
- pub repetition_penalty: Option<f64>,
- pub suffix_repetition_length: Option<i64>,
-}
-
-impl ModelSamplingDefaults {
- pub fn summary(&self) -> String {
- let mut parts = Vec::new();
- if let Some(value) = self.temperature {
- parts.push(format!("temp {value:.2}"));
- }
- if let Some(value) = self.top_k {
- parts.push(format!("top-k {value}"));
- }
- if let Some(value) = self.top_p {
- parts.push(format!("top-p {value:.2}"));
- }
- if let Some(value) = self.min_p {
- parts.push(format!("min-p {value:.2}"));
- }
- if let Some(value) = self.repetition_penalty {
- parts.push(format!("repetition penalty {:.2}", value));
- }
- if let Some(value) = self.suffix_repetition_length {
- parts.push(format!("suffix repetition length {:.2}", value));
- }
- if parts.is_empty() {
- "model defaults".to_string()
- } else {
- parts.join(", ")
- }
- }
-}
-
-#[derive(Debug, Clone, Copy, PartialEq, Default)]
-pub struct ModelCapabilities {
- pub thinking: ThinkingSupport,
- pub sampling_defaults: ModelSamplingDefaults,
-}
-
-impl ModelCapabilities {
- pub async fn load(
- engine: &Engine,
- model: &Model,
- ) -> Self {
- if model.is_remote() {
- return Self {
- thinking: ThinkingSupport::Levels(ReasoningEffort::Default),
- sampling_defaults: ModelSamplingDefaults::default(),
- };
- }
- let Some(path) = engine.model_path(model).await else {
- return Self::default();
- };
- let raw = tokio::fs::read_to_string(Path::new(&path).join("config.json")).await.ok();
- raw.and_then(|raw| Self::from_config(&raw)).unwrap_or_default()
- }
-
- fn from_config(raw: &str) -> Option<Self> {
- let json: Value = serde_json::from_str(raw).ok()?;
-
- let codec = json.get("token_codec_config");
- let template = codec.and_then(|codec| codec.get("prompt_template")).and_then(Value::as_str).unwrap_or_default();
- let emits_reasoning =
- codec.and_then(|codec| codec.get("output_parser_regex")).map(|value| !value.is_null()).unwrap_or(false);
- let thinking = if template.contains("enable_thinking") {
- ThinkingSupport::Toggle(true)
- } else if emits_reasoning {
- ThinkingSupport::AlwaysOn
- } else {
- ThinkingSupport::Unsupported
- };
-
- let generation = json.get("generation_config");
- let field = |key: &str| generation.and_then(|generation| generation.get(key));
- let sampling_defaults = ModelSamplingDefaults {
- temperature: field("temperature").and_then(Value::as_f64),
- top_k: field("top_k").and_then(Value::as_i64),
- top_p: field("top_p").and_then(Value::as_f64),
- min_p: field("min_p").and_then(Value::as_f64),
- repetition_penalty: field("repetition_penalty").and_then(Value::as_f64),
- suffix_repetition_length: field("suffix_repetition_length").and_then(Value::as_i64),
- };
-
- Some(Self {
- thinking,
- sampling_defaults,
- })
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn toggle_emits_explicit_effort_each_state() {
- assert_eq!(ThinkingSupport::Toggle(true).reasoning_effort(), Some(ReasoningEffort::Default));
- assert_eq!(ThinkingSupport::Toggle(false).reasoning_effort(), Some(ReasoningEffort::Disabled));
- }
-
- #[test]
- fn toggle_round_trips_through_preference() {
- let support = ThinkingSupport::Toggle(true);
- let enabled = ThinkingPreference {
- enabled: true,
- ..ThinkingPreference::default()
- };
- let disabled = ThinkingPreference {
- enabled: false,
- ..ThinkingPreference::default()
- };
- assert_eq!(support.with_preference(&enabled).reasoning_effort(), Some(ReasoningEffort::Default));
- assert_eq!(support.with_preference(&disabled).reasoning_effort(), Some(ReasoningEffort::Disabled));
- }
-
- #[test]
- fn non_adjustable_support_emits_no_effort() {
- assert_eq!(ThinkingSupport::AlwaysOn.reasoning_effort(), None);
- assert_eq!(ThinkingSupport::Unsupported.reasoning_effort(), None);
- assert_eq!(ThinkingSupport::Levels(ReasoningEffort::Default).reasoning_effort(), None);
- assert_eq!(ThinkingSupport::Levels(ReasoningEffort::High).reasoning_effort(), Some(ReasoningEffort::High));
- }
-
- #[test]
- fn fulfill_requested_effort_honors_adjustable_models() {
- assert_eq!(
- ThinkingSupport::Levels(ReasoningEffort::Default).fulfill_requested_effort(ReasoningEffort::High),
- Ok(Some(ReasoningEffort::High))
- );
- assert_eq!(
- ThinkingSupport::Levels(ReasoningEffort::Default).fulfill_requested_effort(ReasoningEffort::Default),
- Ok(None)
- );
- assert_eq!(
- ThinkingSupport::Toggle(true).fulfill_requested_effort(ReasoningEffort::Low),
- Ok(Some(ReasoningEffort::Default))
- );
- assert_eq!(
- ThinkingSupport::Toggle(true).fulfill_requested_effort(ReasoningEffort::Disabled),
- Ok(Some(ReasoningEffort::Disabled))
- );
- }
-
- #[test]
- fn fulfill_requested_effort_rejects_what_fixed_models_cannot_do() {
- assert_eq!(ThinkingSupport::AlwaysOn.fulfill_requested_effort(ReasoningEffort::High), Ok(None));
- assert!(ThinkingSupport::AlwaysOn.fulfill_requested_effort(ReasoningEffort::Disabled).is_err());
- assert_eq!(ThinkingSupport::Unsupported.fulfill_requested_effort(ReasoningEffort::Disabled), Ok(None));
- assert!(ThinkingSupport::Unsupported.fulfill_requested_effort(ReasoningEffort::Low).is_err());
- }
-}
diff --git a/crates/legacy/cli/src/common/thinking.rs b/crates/legacy/cli/src/common/thinking.rs
new file mode 100644
index 000000000..b4520c10a
--- /dev/null
+++ b/crates/legacy/cli/src/common/thinking.rs
@@ -0,0 +1,335 @@
+use hanashi::chat::EncodingConfig;
+use serde::{Deserialize, Serialize};
+use shoji::types::{basic::ReasoningEffort, model::Model};
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
+#[serde(default)]
+pub struct ThinkingPreference {
+ pub level: ReasoningEffort,
+ pub enabled: bool,
+}
+
+impl Default for ThinkingPreference {
+ fn default() -> Self {
+ Self {
+ level: ReasoningEffort::Default,
+ enabled: true,
+ }
+ }
+}
+
+const EFFORT_ORDER: [ReasoningEffort; 6] = [
+ ReasoningEffort::Default,
+ ReasoningEffort::Low,
+ ReasoningEffort::Medium,
+ ReasoningEffort::High,
+ ReasoningEffort::XHigh,
+ ReasoningEffort::Disabled,
+];
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub struct ReasoningEffortSet(u8);
+
+impl ReasoningEffortSet {
+ pub const ALL: Self = Self(0b111111);
+
+ fn bit(effort: ReasoningEffort) -> u8 {
+ match effort {
+ ReasoningEffort::Default => 1 << 0,
+ ReasoningEffort::Low => 1 << 1,
+ ReasoningEffort::Medium => 1 << 2,
+ ReasoningEffort::High => 1 << 3,
+ ReasoningEffort::XHigh => 1 << 4,
+ ReasoningEffort::Disabled => 1 << 5,
+ }
+ }
+
+ pub fn contains(
+ self,
+ effort: ReasoningEffort,
+ ) -> bool {
+ self.0 & Self::bit(effort) != 0
+ }
+
+ fn from_efforts(efforts: &[ReasoningEffort]) -> Self {
+ efforts.iter().fold(Self(0), |set, effort| Self(set.0 | Self::bit(*effort)))
+ }
+
+ pub fn iter(self) -> impl Iterator<Item = ReasoningEffort> {
+ EFFORT_ORDER.into_iter().filter(move |effort| self.contains(*effort))
+ }
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
+pub enum ThinkingSupport {
+ Levels {
+ effort: ReasoningEffort,
+ supported: ReasoningEffortSet,
+ },
+ Toggle(bool),
+ AlwaysOn,
+ #[default]
+ Unsupported,
+}
+
+impl ThinkingSupport {
+ pub fn for_model(model: &Model) -> Self {
+ if model.is_remote() {
+ return Self::Levels {
+ effort: ReasoningEffort::Default,
+ supported: ReasoningEffortSet::ALL,
+ };
+ }
+ let Some(value) = model.encoding.as_ref() else {
+ return Self::Unsupported;
+ };
+ let config = match serde_json::from_str::<EncodingConfig>(&value.json) {
+ Ok(config) => config,
+ Err(error) => {
+ tracing::warn!(?error, model = %model.identifier, "ignoring invalid encoding config");
+ return Self::Unsupported;
+ },
+ };
+ match config.capabilities() {
+ Ok(capabilities) if capabilities.supports_reasoning => {
+ let supported = ReasoningEffortSet::from_efforts(&capabilities.reasoning_efforts);
+ let has_levels = capabilities.reasoning_efforts.iter().any(|effort| {
+ matches!(
+ effort,
+ ReasoningEffort::Low | ReasoningEffort::Medium | ReasoningEffort::High | ReasoningEffort::XHigh
+ )
+ });
+ if has_levels {
+ Self::Levels {
+ effort: ReasoningEffort::Default,
+ supported,
+ }
+ } else if capabilities.supports_disable_reasoning {
+ Self::Toggle(true)
+ } else {
+ Self::AlwaysOn
+ }
+ },
+ _ => Self::Unsupported,
+ }
+ }
+
+ pub fn is_adjustable(self) -> bool {
+ matches!(self, Self::Levels { .. } | Self::Toggle(_))
+ }
+
+ pub fn with_preference(
+ self,
+ preference: &ThinkingPreference,
+ ) -> Self {
+ match self {
+ Self::Levels {
+ supported,
+ ..
+ } => Self::Levels {
+ effort: if supported.contains(preference.level) {
+ preference.level
+ } else {
+ ReasoningEffort::Default
+ },
+ supported,
+ },
+ Self::Toggle(_) => Self::Toggle(preference.enabled),
+ other => other,
+ }
+ }
+
+ /// Resolve a requested effort against what this model can actually do.
+ /// `Ok(Some(effort))` — emit this effort; `Ok(None)` — the request is already
+ /// satisfied by the model's fixed behavior; `Err` — the requested thinking
+ /// state cannot be produced, so the caller must reject the request rather
+ /// than silently ignore it.
+ pub fn fulfill_requested_effort(
+ self,
+ effort: ReasoningEffort,
+ ) -> Result<Option<ReasoningEffort>, String> {
+ match self {
+ Self::Levels {
+ supported,
+ ..
+ } => {
+ if effort == ReasoningEffort::Default {
+ Ok(None)
+ } else if supported.contains(effort) {
+ Ok(Some(effort))
+ } else {
+ Err(format!("model does not support reasoning effort {effort}"))
+ }
+ },
+ Self::Toggle(_) => Ok(Some(if effort == ReasoningEffort::Disabled {
+ ReasoningEffort::Disabled
+ } else {
+ ReasoningEffort::Default
+ })),
+ Self::AlwaysOn => {
+ if effort == ReasoningEffort::Disabled {
+ Err("model always reasons; reasoning cannot be disabled".to_string())
+ } else {
+ Ok(None)
+ }
+ },
+ Self::Unsupported => {
+ if effort == ReasoningEffort::Disabled {
+ Ok(None)
+ } else {
+ Err("model does not support reasoning".to_string())
+ }
+ },
+ }
+ }
+
+ pub fn reasoning_effort(self) -> Option<ReasoningEffort> {
+ match self {
+ Self::Levels {
+ effort: ReasoningEffort::Default,
+ ..
+ } => None,
+ Self::Levels {
+ effort,
+ ..
+ } => Some(effort),
+ Self::Toggle(true) => Some(ReasoningEffort::Default),
+ Self::Toggle(false) => Some(ReasoningEffort::Disabled),
+ Self::AlwaysOn | Self::Unsupported => None,
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use shoji::types::{
+ basic::Value,
+ model::{ModelAccessibility, ModelReference, ModelSpecialization},
+ };
+
+ use super::*;
+
+ fn levels(
+ effort: ReasoningEffort,
+ supported: &[ReasoningEffort],
+ ) -> ThinkingSupport {
+ ThinkingSupport::Levels {
+ effort,
+ supported: ReasoningEffortSet::from_efforts(supported),
+ }
+ }
+
+ const QWEN38_EFFORTS: [ReasoningEffort; 5] = [
+ ReasoningEffort::Default,
+ ReasoningEffort::Low,
+ ReasoningEffort::Medium,
+ ReasoningEffort::XHigh,
+ ReasoningEffort::Disabled,
+ ];
+
+ fn model_with_encoding(encoding: Option<Value>) -> Model {
+ Model::external(
+ "test".to_string(),
+ "test".to_string(),
+ "test".to_string(),
+ "uzu".to_string(),
+ "uzu".to_string(),
+ "0.0".to_string(),
+ vec![ModelSpecialization::Chat {}],
+ ModelAccessibility::Local {
+ reference: ModelReference::Local {
+ path: "/nonexistent".to_string(),
+ },
+ },
+ encoding,
+ )
+ }
+
+ fn encoding(name: &str) -> Value {
+ Value::from(serde_json::json!({"name": name, "type": "hanashi"}))
+ }
+
+ #[test]
+ fn for_model_maps_encoding_capabilities() {
+ assert_eq!(
+ ThinkingSupport::for_model(&model_with_encoding(Some(encoding("qwen3.8")))),
+ levels(ReasoningEffort::Default, &QWEN38_EFFORTS)
+ );
+ assert_eq!(
+ ThinkingSupport::for_model(&model_with_encoding(Some(encoding("qwen3.5")))),
+ ThinkingSupport::Toggle(true)
+ );
+ assert_eq!(
+ ThinkingSupport::for_model(&model_with_encoding(Some(encoding("qwen3-thinking")))),
+ ThinkingSupport::AlwaysOn
+ );
+ assert_eq!(
+ ThinkingSupport::for_model(&model_with_encoding(Some(encoding("gemma-3")))),
+ ThinkingSupport::Unsupported
+ );
+ assert_eq!(ThinkingSupport::for_model(&model_with_encoding(None)), ThinkingSupport::Unsupported);
+ }
+
+ #[test]
+ fn toggle_emits_explicit_effort_each_state() {
+ assert_eq!(ThinkingSupport::Toggle(true).reasoning_effort(), Some(ReasoningEffort::Default));
+ assert_eq!(ThinkingSupport::Toggle(false).reasoning_effort(), Some(ReasoningEffort::Disabled));
+ }
+
+ #[test]
+ fn toggle_round_trips_through_preference() {
+ let support = ThinkingSupport::Toggle(true);
+ let enabled = ThinkingPreference {
+ enabled: true,
+ ..ThinkingPreference::default()
+ };
+ let disabled = ThinkingPreference {
+ enabled: false,
+ ..ThinkingPreference::default()
+ };
+ assert_eq!(support.with_preference(&enabled).reasoning_effort(), Some(ReasoningEffort::Default));
+ assert_eq!(support.with_preference(&disabled).reasoning_effort(), Some(ReasoningEffort::Disabled));
+ }
+
+ #[test]
+ fn levels_fall_back_to_default_for_unsupported_preference() {
+ let support = levels(ReasoningEffort::Default, &QWEN38_EFFORTS);
+ let preference = ThinkingPreference {
+ level: ReasoningEffort::High,
+ ..ThinkingPreference::default()
+ };
+ assert_eq!(support.with_preference(&preference).reasoning_effort(), None);
+ }
+
+ #[test]
+ fn non_adjustable_support_emits_no_effort() {
+ assert_eq!(ThinkingSupport::AlwaysOn.reasoning_effort(), None);
+ assert_eq!(ThinkingSupport::Unsupported.reasoning_effort(), None);
+ assert_eq!(levels(ReasoningEffort::Default, &QWEN38_EFFORTS).reasoning_effort(), None);
+ assert_eq!(levels(ReasoningEffort::Low, &QWEN38_EFFORTS).reasoning_effort(), Some(ReasoningEffort::Low));
+ }
+
+ #[test]
+ fn fulfill_requested_effort_honors_adjustable_models() {
+ let support = levels(ReasoningEffort::Default, &QWEN38_EFFORTS);
+ assert_eq!(support.fulfill_requested_effort(ReasoningEffort::XHigh), Ok(Some(ReasoningEffort::XHigh)));
+ assert_eq!(support.fulfill_requested_effort(ReasoningEffort::Default), Ok(None));
+ assert!(support.fulfill_requested_effort(ReasoningEffort::High).is_err());
+ assert_eq!(
+ ThinkingSupport::Toggle(true).fulfill_requested_effort(ReasoningEffort::Low),
+ Ok(Some(ReasoningEffort::Default))
+ );
+ assert_eq!(
+ ThinkingSupport::Toggle(true).fulfill_requested_effort(ReasoningEffort::Disabled),
+ Ok(Some(ReasoningEffort::Disabled))
+ );
+ }
+
+ #[test]
+ fn fulfill_requested_effort_rejects_what_fixed_models_cannot_do() {
+ assert_eq!(ThinkingSupport::AlwaysOn.fulfill_requested_effort(ReasoningEffort::High), Ok(None));
+ assert!(ThinkingSupport::AlwaysOn.fulfill_requested_effort(ReasoningEffort::Disabled).is_err());
+ assert_eq!(ThinkingSupport::Unsupported.fulfill_requested_effort(ReasoningEffort::Disabled), Ok(None));
+ assert!(ThinkingSupport::Unsupported.fulfill_requested_effort(ReasoningEffort::Low).is_err());
+ }
+}
diff --git a/crates/legacy/cli/src/interactive/components/application.rs b/crates/legacy/cli/src/interactive/components/application.rs
index 71351a493..3a93f0bb2 100644
--- a/crates/legacy/cli/src/interactive/components/application.rs
+++ b/crates/legacy/cli/src/interactive/components/application.rs
@@ -1,7 +1,10 @@
use std::path::PathBuf;
use iocraft::prelude::*;
-use shoji::types::{basic::ReasoningEffort, model::Model};
+use shoji::types::{
+ basic::{ReasoningEffort, SamplingParameters},
+ model::Model,
+};
use uzu::{
engine::Engine,
settings::Settings,
@@ -9,7 +12,7 @@ use uzu::{
};
use crate::{
- common::model_capabilities::{ModelCapabilities, ThinkingPreference},
+ common::thinking::{ThinkingPreference, ThinkingSupport},
interactive::{
APP_IDENTIFIER,
components::{CommandInput, HistoryCell, HistoryCellType, Logo, Preferences, SelectedModel, Theme},
@@ -34,7 +37,11 @@ pub struct ModelState {
pub model: Model,
pub download_state: DownloadState,
pub session_state: Option<Box<dyn SessionState>>,
- pub capabilities: ModelCapabilities,
+ pub thinking: ThinkingSupport,
+ pub sampling_defaults: SamplingParameters,
+ /// The thinking effort is baked into the prompt on the first turn and
+ /// cannot be changed afterwards.
+ pub thinking_locked: bool,
}
pub struct ApplicationState {
@@ -168,7 +175,9 @@ pub fn Application(
model,
download_state: DownloadState::not_downloaded(0),
session_state: None,
- capabilities: ModelCapabilities::default(),
+ thinking: ThinkingSupport::default(),
+ sampling_defaults: SamplingParameters::default(),
+ thinking_locked: false,
});
},
Ok(None) => {
diff --git a/crates/legacy/cli/src/interactive/components/preferences.rs b/crates/legacy/cli/src/interactive/components/preferences.rs
index 0452c4a34..500325497 100644
--- a/crates/legacy/cli/src/interactive/components/preferences.rs
+++ b/crates/legacy/cli/src/interactive/components/preferences.rs
@@ -3,7 +3,7 @@ use std::{fs, io, path::Path};
use serde::{Deserialize, Serialize};
use crate::{
- common::model_capabilities::ThinkingPreference,
+ common::thinking::ThinkingPreference,
interactive::{components::Theme, sampling::SamplingPreferences},
};
diff --git a/crates/legacy/cli/src/interactive/components/selected_model.rs b/crates/legacy/cli/src/interactive/components/selected_model.rs
index 5276d7521..f44e929bb 100644
--- a/crates/legacy/cli/src/interactive/components/selected_model.rs
+++ b/crates/legacy/cli/src/interactive/components/selected_model.rs
@@ -5,7 +5,7 @@ use tokio_stream::StreamExt;
use uzu::storage::types::DownloadPhase;
use crate::{
- common::model_capabilities::{ModelCapabilities, ThinkingSupport},
+ common::thinking::ThinkingSupport,
interactive::components::{ApplicationState, ProgressBar, ThinkingSupportExt},
};
@@ -35,9 +35,9 @@ pub fn SelectedModel(
let Some(model) = model else {
return;
};
- let capabilities = ModelCapabilities::load(&engine, &model).await;
+ let thinking = ThinkingSupport::for_model(&model);
if let Some(model_state) = state.write().model_state.as_mut() {
- model_state.capabilities = capabilities;
+ model_state.thinking = thinking;
}
if !model.is_downloadable() {
return;
@@ -82,9 +82,9 @@ pub fn SelectedModel(
model_state.download_state = event_state;
}
if became_downloaded {
- let capabilities = ModelCapabilities::load(&engine, &model).await;
+ let thinking = ThinkingSupport::for_model(&model);
if let Some(model_state) = state.write().model_state.as_mut() {
- model_state.capabilities = capabilities;
+ model_state.thinking = thinking;
}
}
}
@@ -172,12 +172,12 @@ pub fn SelectedModel(
let thinking = state.read().thinking();
let model_data = state.read().model_state.as_ref().map(|model_state| {
let session_status = model_state.session_state.as_deref().and_then(|session_state| session_state.status_text());
- (model_state.model.clone(), model_state.download_state.clone(), session_status, model_state.capabilities)
+ (model_state.model.clone(), model_state.download_state.clone(), session_status, model_state.thinking)
});
let view: AnyElement<'static> = match model_data {
None => element! { View }.into(),
- Some((model, download_state, session_status, capabilities)) => {
+ Some((model, download_state, session_status, thinking_support)) => {
let is_downloaded = matches!(download_state.phase, DownloadPhase::Downloaded {});
let is_downloading = matches!(download_state.phase, DownloadPhase::Downloading {});
let status = if is_downloading {
@@ -202,7 +202,7 @@ pub fn SelectedModel(
let padding = theme.padding();
let padding_wide = theme.padding_wide();
let chat_indicator = (model.is_chat_capable() && (is_downloaded || !model.is_downloadable())).then(|| {
- let thinking = match capabilities.thinking.with_preference(&thinking) {
+ let thinking = match thinking_support.with_preference(&thinking) {
ThinkingSupport::Unsupported => None,
support => Some(support.value_label()),
};
diff --git a/crates/legacy/cli/src/interactive/components/thinking_support_ext.rs b/crates/legacy/cli/src/interactive/components/thinking_support_ext.rs
index e16516c39..08492435e 100644
--- a/crates/legacy/cli/src/interactive/components/thinking_support_ext.rs
+++ b/crates/legacy/cli/src/interactive/components/thinking_support_ext.rs
@@ -1,17 +1,6 @@
use shoji::types::basic::ReasoningEffort;
-use crate::{
- common::model_capabilities::{ThinkingPreference, ThinkingSupport},
- interactive::util::cycle,
-};
-
-const LEVELS: [ReasoningEffort; 5] = [
- ReasoningEffort::Default,
- ReasoningEffort::Low,
- ReasoningEffort::Medium,
- ReasoningEffort::High,
- ReasoningEffort::Disabled,
-];
+use crate::common::thinking::{ThinkingPreference, ThinkingSupport};
fn level_label(effort: ReasoningEffort) -> &'static str {
match effort {
@@ -19,6 +8,7 @@ fn level_label(effort: ReasoningEffort) -> &'static str {
ReasoningEffort::Low => "low",
ReasoningEffort::Medium => "medium",
ReasoningEffort::High => "high",
+ ReasoningEffort::XHigh => "xhigh",
ReasoningEffort::Disabled => "off",
}
}
@@ -43,7 +33,17 @@ impl ThinkingSupportExt for ThinkingSupport {
delta: i64,
) -> ThinkingSupport {
match self {
- ThinkingSupport::Levels(effort) => ThinkingSupport::Levels(cycle(&LEVELS, effort, delta as isize)),
+ ThinkingSupport::Levels {
+ effort,
+ supported,
+ } => {
+ let levels = supported.iter().collect::<Vec<_>>();
+ let effort = crate::interactive::util::cycle(&levels, effort, delta as isize);
+ ThinkingSupport::Levels {
+ effort,
+ supported,
+ }
+ },
ThinkingSupport::Toggle(value) => ThinkingSupport::Toggle(!value),
other => other,
}
@@ -54,7 +54,10 @@ impl ThinkingSupportExt for ThinkingSupport {
preference: &mut ThinkingPreference,
) {
match self {
- ThinkingSupport::Levels(effort) => preference.level = effort,
+ ThinkingSupport::Levels {
+ effort,
+ ..
+ } => preference.level = effort,
ThinkingSupport::Toggle(value) => preference.enabled = value,
ThinkingSupport::AlwaysOn | ThinkingSupport::Unsupported => {},
}
@@ -62,7 +65,10 @@ impl ThinkingSupportExt for ThinkingSupport {
fn value_label(self) -> &'static str {
match self {
- ThinkingSupport::Levels(effort) => level_label(effort),
+ ThinkingSupport::Levels {
+ effort,
+ ..
+ } => level_label(effort),
ThinkingSupport::Toggle(true) => "on",
ThinkingSupport::Toggle(false) => "off",
ThinkingSupport::AlwaysOn => "always on",
diff --git a/crates/legacy/cli/src/interactive/flows/models.rs b/crates/legacy/cli/src/interactive/flows/models.rs
index 1c635b820..4a705d020 100644
--- a/crates/legacy/cli/src/interactive/flows/models.rs
+++ b/crates/legacy/cli/src/interactive/flows/models.rs
@@ -1,11 +1,11 @@
use std::{collections::HashMap, sync::Arc};
use iocraft::prelude::*;
-use shoji::types::model::Model;
+use shoji::types::{basic::SamplingParameters, model::Model};
use uzu::storage::types::DownloadState;
use crate::{
- common::model_capabilities::ModelCapabilities,
+ common::thinking::ThinkingSupport,
interactive::{
components::{ApplicationState, Loading, ModelState, Selector, SelectorItem, SelectorStyle},
flows::{Flow, FlowEvent},
@@ -111,7 +111,9 @@ fn Models(
model: model.clone(),
download_state,
session_state: None,
- capabilities: ModelCapabilities::default(),
+ thinking: ThinkingSupport::default(),
+ sampling_defaults: SamplingParameters::default(),
+ thinking_locked: false,
});
let mut preferences = app_state.preferences().clone();
preferences.selected_model_id = Some(model.identifier.clone());
diff --git a/crates/legacy/cli/src/interactive/flows/settings.rs b/crates/legacy/cli/src/interactive/flows/settings.rs
index a3da60606..e042ab651 100644
--- a/crates/legacy/cli/src/interactive/flows/settings.rs
+++ b/crates/legacy/cli/src/interactive/flows/settings.rs
@@ -1,11 +1,12 @@
use iocraft::prelude::*;
+use shoji::types::basic::SamplingParameters;
use crate::{
- common::model_capabilities::{ModelSamplingDefaults, ThinkingSupport},
+ common::thinking::ThinkingSupport,
interactive::{
components::{ApplicationState, Preferences, Theme, ThinkingSupportExt},
flows::{Flow, FlowEvent},
- sampling::SamplingMode,
+ sampling::{SamplingMode, SamplingParametersExt},
},
};
@@ -49,9 +50,10 @@ enum Field {
fn visible_fields(
preferences: &Preferences,
support: ThinkingSupport,
+ thinking_locked: bool,
) -> Vec<Field> {
let mut fields = Vec::new();
- if support.is_adjustable() {
+ if support.is_adjustable() && !thinking_locked {
fields.push(Field::Thinking);
}
fields.push(Field::SamplingMode);
@@ -117,7 +119,7 @@ fn toggle(
preferences: &mut Preferences,
field: Field,
support: ThinkingSupport,
- defaults: ModelSamplingDefaults,
+ defaults: SamplingParameters,
) {
let sampling = &mut preferences.sampling;
match field {
@@ -207,16 +209,17 @@ fn SettingsFlowView(
let on_event = std::mem::take(&mut props.on_event);
let state = *hooks.use_context::<State<ApplicationState>>();
- let capabilities =
- state.read().model_state.as_ref().map(|model_state| model_state.capabilities).unwrap_or_default();
- let support = capabilities.thinking;
- let defaults = capabilities.sampling_defaults;
+ let support = state.read().model_state.as_ref().map(|model_state| model_state.thinking).unwrap_or_default();
+ let defaults =
+ state.read().model_state.as_ref().map(|model_state| model_state.sampling_defaults).unwrap_or_default();
+ let thinking_locked =
+ state.read().model_state.as_ref().map(|model_state| model_state.thinking_locked).unwrap_or(false);
let mut draft = hooks.use_state(|| state.read().preferences().clone());
let mut selected_index = hooks.use_state(|| 0usize);
let preferences = draft.read().clone();
- let fields = visible_fields(&preferences, support);
+ let fields = visible_fields(&preferences, support, thinking_locked);
if selected_index.get() >= fields.len() {
selected_index.set(fields.len().saturating_sub(1));
}
@@ -235,7 +238,7 @@ fn SettingsFlowView(
}
let preferences = draft.read().clone();
- let fields = visible_fields(&preferences, support);
+ let fields = visible_fields(&preferences, support, thinking_locked);
if fields.is_empty() {
return;
}
@@ -297,7 +300,9 @@ fn SettingsFlowView(
let padding = theme.padding();
let mut rows: Vec<AnyElement<'static>> = vec![section_header("Thinking", &theme)];
- if support.is_adjustable() {
+ if thinking_locked && support.is_adjustable() {
+ rows.push(info_row("Thinking", thinking_summary(support, &preferences), &theme));
+ } else if support.is_adjustable() {
rows.push(field_row(Field::Thinking, &preferences, selected, &theme, support, defaults));
} else {
rows.push(info_row("Thinking", support.value_label(), &theme));
@@ -374,7 +379,7 @@ fn field_row(
selected: Option<Field>,
theme: &Theme,
support: ThinkingSupport,
- defaults: ModelSamplingDefaults,
+ defaults: SamplingParameters,
) -> AnyElement<'static> {
let is_selected = selected == Some(field);
let marker = if is_selected {
diff --git a/crates/legacy/cli/src/interactive/sampling.rs b/crates/legacy/cli/src/interactive/sampling.rs
index 243fd676f..97b8825a5 100644
--- a/crates/legacy/cli/src/interactive/sampling.rs
+++ b/crates/legacy/cli/src/interactive/sampling.rs
@@ -1,5 +1,5 @@
use rocket::serde::{Deserialize, Serialize};
-use shoji::types::basic::{SamplingMethod, SamplingPolicy};
+use shoji::types::basic::{SamplingMethod, SamplingParameters, SamplingPolicy};
use crate::interactive::util::cycle;
@@ -112,3 +112,36 @@ impl SamplingPreferences {
}
}
}
+
+pub trait SamplingParametersExt {
+ fn summary(&self) -> String;
+}
+
+impl SamplingParametersExt for SamplingParameters {
+ fn summary(&self) -> String {
+ let mut parts = Vec::new();
+ if let Some(value) = self.temperature {
+ parts.push(format!("temp {value:.2}"));
+ }
+ if let Some(value) = self.top_k {
+ parts.push(format!("top-k {value}"));
+ }
+ if let Some(value) = self.top_p {
+ parts.push(format!("top-p {value:.2}"));
+ }
+ if let Some(value) = self.min_p {
+ parts.push(format!("min-p {value:.2}"));
+ }
+ if let Some(value) = self.repetition_penalty {
+ parts.push(format!("repetition penalty {:.2}", value));
+ }
+ if let Some(value) = self.suffix_repetition_length {
+ parts.push(format!("suffix repetition length {:.2}", value));
+ }
+ if parts.is_empty() {
+ "model defaults".to_string()
+ } else {
+ parts.join(", ")
+ }
+ }
+}
diff --git a/crates/legacy/cli/src/interactive/sessions/chat.rs b/crates/legacy/cli/src/interactive/sessions/chat.rs
index 681211786..72f07fcc6 100644
--- a/crates/legacy/cli/src/interactive/sessions/chat.rs
+++ b/crates/legacy/cli/src/interactive/sessions/chat.rs
@@ -140,9 +140,11 @@ pub async fn ensure_session(
},
};
+ let sampling_defaults = session.sampling_defaults().await.unwrap_or_default();
{
let mut state = state.write();
if let Some(model_state) = state.model_state.as_mut() {
+ model_state.sampling_defaults = sampling_defaults;
model_state.session_state = Some(Box::new(ChatSessionState::idle(session.clone())));
}
}
@@ -158,7 +160,7 @@ pub async fn run_session(
let (thinking_support, thinking_override, thinking) = {
let state = state.read();
(
- state.model_state.as_ref().map(|model_state| model_state.capabilities.thinking).unwrap_or_default(),
+ state.model_state.as_ref().map(|model_state| model_state.thinking).unwrap_or_default(),
state.reasoning_effort_override(),
state.thinking(),
)
@@ -189,6 +191,9 @@ pub async fn run_session(
let reply_config = ChatReplyConfig::default().with_sampling_policy(state.read().preferences().sampling.policy());
{
let mut state = state.write();
+ if let Some(model_state) = state.model_state.as_mut() {
+ model_state.thinking_locked = true;
+ }
if let Some(chat_state) = chat_state_mut(&mut state) {
chat_state.pending_items = Vec::new();
chat_state.pending_stats = None;
diff --git a/crates/legacy/cli/src/server/chat_completions.rs b/crates/legacy/cli/src/server/chat_completions.rs
index ecc64899e..70de7d578 100644
--- a/crates/legacy/cli/src/server/chat_completions.rs
+++ b/crates/legacy/cli/src/server/chat_completions.rs
@@ -33,7 +33,7 @@ use uzu::{
};
use crate::{
- common::model_capabilities::ThinkingSupport,
+ common::thinking::ThinkingSupport,
server::{
ServerState,
chat_tool_calls::{
diff --git a/crates/legacy/cli/src/server/runner.rs b/crates/legacy/cli/src/server/runner.rs
index f4b40466a..afc0755ff 100644
--- a/crates/legacy/cli/src/server/runner.rs
+++ b/crates/legacy/cli/src/server/runner.rs
@@ -10,7 +10,7 @@ use uzu::{
};
use crate::{
- common::model_capabilities::ModelCapabilities,
+ common::thinking::ThinkingSupport,
server::{ServerState, handle_chat_completions, handle_models},
};
@@ -38,14 +38,14 @@ pub async fn run_server(
}
spinner.finish_with_message(format!("Loaded: {}", resolved.identifier));
- let capabilities = ModelCapabilities::load(&engine, &resolved).await;
+ let thinking_support = ThinkingSupport::for_model(&resolved);
let session =
engine.chat(resolved.clone(), ChatConfig::default()).await.context("Failed to create chat session")?;
let model_name = resolved.identifier.clone();
let state = ServerState {
model_name: model_name.clone(),
session: Arc::new(Mutex::new(session)),
- thinking_support: capabilities.thinking,
+ thinking_support,
prefix_cache,
};
diff --git a/crates/legacy/cli/src/server/state.rs b/crates/legacy/cli/src/server/state.rs
index 4cc96eaa7..a6fbd3d7d 100644
--- a/crates/legacy/cli/src/server/state.rs
+++ b/crates/legacy/cli/src/server/state.rs
@@ -3,7 +3,7 @@ use std::sync::Arc;
use tokio::sync::Mutex;
use uzu::session::chat::ChatSession;
-use crate::common::model_capabilities::ThinkingSupport;
+use crate::common::thinking::ThinkingSupport;
pub struct ServerState {
pub model_name: String,
diff --git a/crates/legacy/cli/unit/interactive/model_test.rs b/crates/legacy/cli/unit/interactive/model_test.rs
index 4a0ea8a91..960a9824d 100644
--- a/crates/legacy/cli/unit/interactive/model_test.rs
+++ b/crates/legacy/cli/unit/interactive/model_test.rs
@@ -137,7 +137,7 @@ fn checkpoint(
}],
},
},
- encodings: vec![],
+ encoding: None,
}
}
diff --git a/crates/legacy/cli/unit/server/chat_completions_test.rs b/crates/legacy/cli/unit/server/chat_completions_test.rs
index be13a2c31..3ea76baa9 100644
--- a/crates/legacy/cli/unit/server/chat_completions_test.rs
+++ b/crates/legacy/cli/unit/server/chat_completions_test.rs
@@ -1,4 +1,5 @@
use super::*;
+use crate::common::thinking::ReasoningEffortSet;
fn request(json: &str) -> ChatCompletionRequest {
serde_json::from_str(json).expect("valid request json")
@@ -98,6 +99,13 @@ fn malformed_response_format_passes_json_extraction() {
}
}
+fn any_levels() -> ThinkingSupport {
+ ThinkingSupport::Levels {
+ effort: ReasoningEffort::Default,
+ supported: ReasoningEffortSet::ALL,
+ }
+}
+
fn messages_with_support(
json: &str,
thinking_support: ThinkingSupport,
@@ -111,7 +119,7 @@ fn reasoning_effort_prepends_system_message_for_levels_model() {
let messages = messages_with_support(
r#"{"messages":[{"role":"user","content":"hi"}],"reasoning_effort":"high"}"#,
- ThinkingSupport::Levels(ReasoningEffort::Default),
+ any_levels(),
);
assert_eq!(messages.len(), 2);
assert_eq!(messages[0].reasoning_effort(), Some(ReasoningEffort::High));
@@ -122,7 +130,7 @@ fn reasoning_effort_prepends_system_message_for_levels_model() {
fn reasoning_effort_merges_into_leading_system_message() {
let messages = messages_with_support(
r#"{"messages":[{"role":"system","content":"be brief"},{"role":"user","content":"hi"}],"reasoning_effort":"high"}"#,
- ThinkingSupport::Levels(ReasoningEffort::Default),
+ any_levels(),
);
assert_eq!(messages.len(), 2);
assert_eq!(messages[0].role, ChatRole::System {});
@@ -136,7 +144,7 @@ fn reasoning_effort_default_emits_no_system_message() {
r#"{"messages":[{"role":"user","content":"hi"}]}"#,
r#"{"messages":[{"role":"user","content":"hi"}],"reasoning_effort":"default"}"#,
] {
- let messages = messages_with_support(body, ThinkingSupport::Levels(ReasoningEffort::Default));
+ let messages = messages_with_support(body, any_levels());
assert_eq!(messages.len(), 1);
assert!(messages.iter().all(|message| message.reasoning_effort().is_none()));
}
@@ -196,10 +204,7 @@ fn enable_thinking_honored_for_toggle_model() {
#[test]
fn enable_thinking_honored_for_levels_model() {
- let disabled = messages_with_support(
- r#"{"messages":[],"enable_thinking":false}"#,
- ThinkingSupport::Levels(ReasoningEffort::Default),
- );
+ let disabled = messages_with_support(r#"{"messages":[],"enable_thinking":false}"#, any_levels());
assert_eq!(disabled[0].reasoning_effort(), Some(ReasoningEffort::Disabled));
}
@@ -221,17 +226,14 @@ fn enable_thinking_rejects_contradictions() {
r#"{"messages":[],"enable_thinking":false,"reasoning_effort":"high"}"#,
r#"{"messages":[],"enable_thinking":true,"reasoning_effort":"disabled"}"#,
] {
- build_messages(&request(body), ThinkingSupport::Levels(ReasoningEffort::Default))
- .expect_err("contradictory thinking requests should be rejected");
+ build_messages(&request(body), any_levels()).expect_err("contradictory thinking requests should be rejected");
}
}
#[test]
fn enable_thinking_agrees_with_compatible_reasoning_effort() {
- let messages = messages_with_support(
- r#"{"messages":[],"enable_thinking":true,"reasoning_effort":"low"}"#,
- ThinkingSupport::Levels(ReasoningEffort::Default),
- );
+ let messages =
+ messages_with_support(r#"{"messages":[],"enable_thinking":true,"reasoning_effort":"low"}"#, any_levels());
assert_eq!(messages[0].reasoning_effort(), Some(ReasoningEffort::Low));
}
@@ -375,7 +377,7 @@ fn assistant_reasoning_content_round_trips_in_session_block_order() {
{"role":"assistant","reasoning_content":"","content":"no thinking"},
{"role":"user","content":"again"}
]}"#,
- ThinkingSupport::Levels(ReasoningEffort::Default),
+ any_levels(),
);
let assistant = &messages[1];
let kinds = assistant
diff --git a/crates/legacy/cli/unit/server/chat_tool_calls_test.rs b/crates/legacy/cli/unit/server/chat_tool_calls_test.rs
index d6e05885e..b9dd72b0c 100644
--- a/crates/legacy/cli/unit/server/chat_tool_calls_test.rs
+++ b/crates/legacy/cli/unit/server/chat_tool_calls_test.rs
@@ -1,6 +1,6 @@
use super::*;
use crate::{
- common::model_capabilities::ThinkingSupport,
+ common::thinking::ThinkingSupport,
server::chat_completions::{ChatCompletionRequest, build_messages},
};
diff --git a/crates/legacy/hanashi/configs/configs.json b/crates/legacy/hanashi/configs/configs.json
index fc6f274e9..061884f54 100644
--- a/crates/legacy/hanashi/configs/configs.json
+++ b/crates/legacy/hanashi/configs/configs.json
@@ -90,6 +90,13 @@
"tokens": "qwen3.6",
"ordering": "default"
},
+ {
+ "name": "qwen3.8",
+ "parsing": "qwen3.6",
+ "rendering": "qwen3.8",
+ "tokens": "qwen3.6",
+ "ordering": "default"
+ },
{
"name": "muse-glimmer",
"parsing": "muse-glimmer",
diff --git a/crates/legacy/hanashi/configs/rendering/qwen3.8.json b/crates/legacy/hanashi/configs/rendering/qwen3.8.json
new file mode 100644
index 000000000..4476e53d3
--- /dev/null
+++ b/crates/legacy/hanashi/configs/rendering/qwen3.8.json
@@ -0,0 +1,98 @@
+{
+ "jinja": {
+ "template": "{%- set image_count = namespace(value=0) %}\n{%- set video_count = namespace(value=0) %}\n{%- macro render_content(content, do_vision_count, is_system_content=false) %}\n {%- if content is string %}\n {{- content }}\n {%- elif content is iterable and content is not mapping %}\n {%- for item in content %}\n {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}\n {%- if is_system_content %}\n {{- raise_exception('System message cannot contain images.') }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set image_count.value = image_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Picture ' ~ image_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|image_pad|><|vision_end|>' }}\n {%- elif 'video' in item or item.type == 'video' %}\n {%- if is_system_content %}\n {{- raise_exception('System message cannot contain videos.') }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set video_count.value = video_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Video ' ~ video_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|video_pad|><|vision_end|>' }}\n {%- elif 'text' in item %}\n {{- item.text }}\n {%- else %}\n {{- raise_exception('Unexpected item type in content.') }}\n {%- endif %}\n {%- endfor %}\n {%- elif content is none or content is undefined %}\n {{- '' }}\n {%- else %}\n {{- raise_exception('Unexpected content type.') }}\n {%- endif %}\n{%- endmacro %}\n{%- if not messages %}\n {{- raise_exception('No messages provided.') }}\n{%- endif %}\n{%- set reasoning_instructions = '' %}\n{%- if enable_thinking is undefined or enable_thinking is true %}\n {%- set resolved_reasoning_effort = reasoning_effort|default('xhigh') %}\n {%- if resolved_reasoning_effort not in ('xhigh', 'medium', 'low') %}\n {{- raise_exception('Unexpected reasoning effort ' ~ reasoning_effort ~ '. Supported types are xhigh (default), medium, and low.') }}\n {%- endif %}\n {%- if resolved_reasoning_effort == 'xhigh' %}\n {%- set reasoning_instructions = 'Reasoning effort is set to xhigh. Please think carefully through the task, validate key assumptions, consider plausible alternatives, and prioritize correctness, consistency, and clarity in the final answer.' %}\n {%- elif resolved_reasoning_effort == 'low' %}\n {%- set reasoning_instructions = 'Reasoning effort is set to low. Keep your thinking brief and focused, moving directly to the conclusion without unnecessary elaboration.' %}\n {%- endif %}\n{%- endif %}\n{%- if tools and tools is iterable and tools is not mapping %}\n {{- '<|im_start|>system\\n' }}\n {%- if reasoning_instructions %}\n {{- reasoning_instructions + '\\n\\n' }}\n {%- endif %}\n {{- \"# Tools\\n\\nYou have access to the following functions:\\n\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\" }}\n {{- '\\n\\nIf you choose to call a function ONLY reply in the following format with NO suffix:\\n\\n<tool_call>\\n<function=example_function_name>\\n<parameter=example_parameter_1>\\nvalue_1\\n</parameter>\\n<parameter=example_parameter_2>\\nThis is the value for the second parameter\\nthat can span\\nmultiple lines\\n</parameter>\\n</function>\\n</tool_call>\\n\\n<IMPORTANT>\\nReminder:\\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\\n- Required parameters MUST be specified\\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\\n</IMPORTANT>' }}\n {%- if messages[0].role == 'system' %}\n {%- set content = render_content(messages[0].content, false, true)|trim %}\n {%- if content %}\n {{- '\\n\\n' + content }}\n {%- endif %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n{%- else %}\n {%- if messages[0].role == 'system' %}\n {%- set content = render_content(messages[0].content, false, true)|trim %}\n {%- if content %}\n {{- '<|im_start|>system\\n' + (reasoning_instructions + '\\n\\n' if reasoning_instructions else '') + content + '<|im_end|>\\n' }}\n {%- elif reasoning_instructions %}\n {{- '<|im_start|>system\\n' + reasoning_instructions + '<|im_end|>\\n' }}\n {%- endif %}\n {%- elif reasoning_instructions %}\n {{- '<|im_start|>system\\n' + reasoning_instructions + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}\n{%- for message in messages[::-1] %}\n {%- set index = (messages|length - 1) - loop.index0 %}\n {%- if ns.multi_step_tool and message.role == \"user\" %}\n {%- set content = render_content(message.content, false)|trim %}\n {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}\n {%- set ns.multi_step_tool = false %}\n {%- set ns.last_query_index = index %}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if ns.multi_step_tool %}\n {{- raise_exception('No user query found in messages.') }}\n{%- endif %}\n{%- for message in messages %}\n {%- set content = render_content(message.content, true)|trim %}\n {%- if message.role == \"system\" %}\n {%- if not loop.first %}\n {{- raise_exception('System message must be at the beginning.') }}\n {%- endif %}\n {%- elif message.role == \"user\" %}\n {{- '<|im_start|>' + message.role + '\\n' + content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {%- set reasoning_content = '' %}\n {%- if message.reasoning_content is string %}\n {%- set reasoning_content = message.reasoning_content %}\n {%- endif %}\n {%- set reasoning_content = reasoning_content|trim %}\n {%- if preserve_thinking is undefined or preserve_thinking is true or loop.index0 > ns.last_query_index %}\n {{- '<|im_start|>' + message.role + '\\n<think>\\n' + reasoning_content + '\\n</think>\\n\\n' + content }}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- endif %}\n {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {%- if loop.first %}\n {%- if content|trim %}\n {{- '\\n\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- else %}\n {{- '<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- endif %}\n {%- else %}\n {{- '\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- endif %}\n {%- if tool_call.arguments is defined and tool_call.arguments != '' %}\n {%- for args_name, args_value in tool_call.arguments|items %}\n {{- '<parameter=' + args_name + '>\\n' }}\n {%- set args_value = args_value | string if args_value is string else args_value | tojson | safe %}\n {{- args_value }}\n {{- '\\n</parameter>\\n' }}\n {%- endfor %}\n {%- endif %}\n {{- '</function>\\n</tool_call>' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.previtem and loop.previtem.role != \"tool\" %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- content }}\n {{- '\\n</tool_response>' }}\n {%- if not loop.last and loop.nextitem.role != \"tool\" %}\n {{- '<|im_end|>\\n' }}\n {%- elif loop.last %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- else %}\n {{- raise_exception('Unexpected message role.') }}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n {%- if enable_thinking is defined and enable_thinking is false %}\n {{- '<think>\\n\\n</think>\\n\\n' }}\n {%- else %}\n {{- '<think>\\n' }}\n {%- endif %}\n{%- endif %}",
+ "required_functions": [],
+ "preamble_control_key": "add_generation_prompt"
+ },
+ "canonization": {
+ "role_key": "role",
+ "type_key": "type",
+ "text_key": "text",
+ "url_key": "url"
+ },
+ "rendering": {
+ "system": {
+ "role": "system",
+ "message": {
+ "content": {
+ "blocks": [
+ "text"
+ ]
+ }
+ },
+ "context": {
+ "enable_thinking": {
+ "block": "reasoning_effort",
+ "mapping": {
+ "disabled": false,
+ "default": true,
+ "low": true,
+ "medium": true,
+ "xhigh": true
+ }
+ },
+ "reasoning_effort": {
+ "block": "reasoning_effort",
+ "mapping": {
+ "disabled": null,
+ "default": "xhigh",
+ "low": "low",
+ "medium": "medium",
+ "xhigh": "xhigh"
+ }
+ }
+ }
+ },
+ "developer": {
+ "role": "developer",
+ "context": {
+ "tools": {
+ "block": "tools"
+ }
+ }
+ },
+ "user": {
+ "role": "user",
+ "message": {
+ "content": {
+ "required": true,
+ "blocks": [
+ "text"
+ ]
+ }
+ }
+ },
+ "assistant": {
+ "role": "assistant",
+ "message": {
+ "content": {
+ "blocks": [
+ "text"
+ ]
+ },
+ "reasoning_content": {
+ "block": "reasoning"
+ },
+ "tool_calls": {
+ "disable_raw": true,
+ "blocks": [
+ "tool_call",
+ "tool_call_candidate"
+ ]
+ }
+ }
+ },
+ "tool": {
+ "role": "tool",
+ "message": {
+ "content": {
+ "required": true,
+ "blocks": [
+ "tool_call_result"
+ ],
+ "limit": 1
+ }
+ }
+ }
+ }
+}
diff --git a/crates/legacy/hanashi/src/chat/config.rs b/crates/legacy/hanashi/src/chat/config.rs
index 326455b67..441f8a302 100644
--- a/crates/legacy/hanashi/src/chat/config.rs
+++ b/crates/legacy/hanashi/src/chat/config.rs
@@ -1,5 +1,5 @@
use serde::{Deserialize, Serialize};
-use shoji::types::session::chat::ChatModelCapabilities;
+use shoji::types::{basic::Value, session::chat::ChatModelCapabilities};
use crate::chat::{Error, hanashi::config::HanashiConfig, harmony::HarmonyConfig};
@@ -17,8 +17,16 @@ pub enum EncodingConfig {
}
impl EncodingConfig {
- #[allow(dead_code)]
- fn capabilities(&self) -> Result<ChatModelCapabilities, Error> {
+ pub fn select(encodings: &[Value]) -> Option<Value> {
+ let parse = |value: &Value| serde_json::from_str::<EncodingConfig>(&value.json).ok();
+ encodings
+ .iter()
+ .find(|value| matches!(parse(value), Some(EncodingConfig::Harmony { .. })))
+ .or_else(|| encodings.iter().find(|value| parse(value).is_some()))
+ .cloned()
+ }
+
+ pub fn capabilities(&self) -> Result<ChatModelCapabilities, Error> {
match self {
EncodingConfig::Hanashi {
config,
diff --git a/crates/legacy/hanashi/src/chat/hanashi/config/mod.rs b/crates/legacy/hanashi/src/chat/hanashi/config/mod.rs
index b1c6e2920..b04a542bf 100644
--- a/crates/legacy/hanashi/src/chat/hanashi/config/mod.rs
+++ b/crates/legacy/hanashi/src/chat/hanashi/config/mod.rs
@@ -56,6 +56,8 @@ pub enum HanashiConfig {
Qwen35,
#[serde(rename = "qwen3.6")]
Qwen36,
+ #[serde(rename = "qwen3.8")]
+ Qwen38,
#[serde(rename = "muse-glimmer")]
MuseGlimmer,
}
@@ -76,16 +78,23 @@ impl HanashiConfig {
})
.is_none_or(|limit| limit > 1);
- let supports_disable_reasoning = rendering
+ let reasoning_effort_mapping = rendering
.get_rendering_field_for_block_type(&ChatContentBlockType::ReasoningEffort)
- .is_some_and(|field| match &field.config {
+ .and_then(|field| match &field.config {
FieldConfig::Unique {
- mapping: Some(mapping),
+ mapping,
..
- } => mapping.contains_key(ReasoningEffort::Disabled.to_string().as_str()),
- _ => false,
+ } => mapping.as_ref(),
+ _ => None,
});
+ let supports_disable_reasoning = reasoning_effort_mapping
+ .is_some_and(|mapping| mapping.contains_key(ReasoningEffort::Disabled.to_string().as_str()));
+
+ let reasoning_efforts = reasoning_effort_mapping
+ .map(|mapping| mapping.keys().filter_map(|key| key.parse::<ReasoningEffort>().ok()).collect::<Vec<_>>())
+ .unwrap_or_default();
+
let tools_role_and_field = rendering.get_rendering_role_and_field_for_block_type(&ChatContentBlockType::Tools);
let supports_tools = tools_role_and_field.is_some();
let requires_tools = tools_role_and_field
@@ -97,6 +106,7 @@ impl HanashiConfig {
.get_rendering_field_for_block_type(&ChatContentBlockType::Reasoning)
.is_some(),
supports_disable_reasoning,
+ reasoning_efforts,
supports_tools,
supports_multiple_tool_calls,
requires_tools,
@@ -118,6 +128,7 @@ impl HanashiConfig {
HanashiConfig::Qwen3Thinking => resolve_bundled_config("qwen3-thinking"),
HanashiConfig::Qwen35 => resolve_bundled_config("qwen3.5"),
HanashiConfig::Qwen36 => resolve_bundled_config("qwen3.6"),
+ HanashiConfig::Qwen38 => resolve_bundled_config("qwen3.8"),
HanashiConfig::MuseGlimmer => resolve_bundled_config("muse-glimmer"),
HanashiConfig::Custom {
config,
diff --git a/crates/legacy/hanashi/src/chat/hanashi/messages/error.rs b/crates/legacy/hanashi/src/chat/hanashi/messages/error.rs
index 07430a355..7fc13c6ab 100644
--- a/crates/legacy/hanashi/src/chat/hanashi/messages/error.rs
+++ b/crates/legacy/hanashi/src/chat/hanashi/messages/error.rs
@@ -38,11 +38,6 @@ pub enum Error {
role: ChatRole,
field: String,
},
- #[error("Block type '{block_type}' is assigned to multiple fields for role '{role}'")]
- DuplicateBlock {
- role: ChatRole,
- block_type: ChatContentBlockType,
- },
#[error("Limit of {limit} exceeded for '{block_type}' on role '{role}'")]
LimitExceeded {
role: ChatRole,
diff --git a/crates/legacy/hanashi/src/chat/hanashi/messages/rendered/message.rs b/crates/legacy/hanashi/src/chat/hanashi/messages/rendered/message.rs
index ce2ba7ca1..da95766d0 100644
--- a/crates/legacy/hanashi/src/chat/hanashi/messages/rendered/message.rs
+++ b/crates/legacy/hanashi/src/chat/hanashi/messages/rendered/message.rs
@@ -28,32 +28,6 @@ impl Message {
role: role.clone(),
})?;
- // Validate no duplicate block types across fields
- let mut seen_block_types: IndexMap<ChatContentBlockType, String> = IndexMap::new();
- for (field_name, field) in config.message.iter().chain(config.context.iter()) {
- let block_types = match &field.config {
- FieldConfig::Unique {
- block,
- ..
- } => vec![block.clone()],
- FieldConfig::Collected {
- blocks,
- ..
- } => blocks.clone(),
- };
- for block_type in block_types {
- if let Some(existing_field) = seen_block_types.get(&block_type)
- && existing_field != field_name
- {
- return Err(Error::DuplicateBlock {
- role: role.clone(),
- block_type,
- });
- }
- seen_block_types.insert(block_type, field_name.clone());
- }
- }
-
// Determine which block types should get raw canonical serialization
let mut raw_types: Vec<ChatContentBlockType> = Vec::new();
for (_, field) in config.message.iter().chain(config.context.iter()) {
@@ -100,12 +74,14 @@ impl Message {
let mut matched = false;
for (fields, destination) in destinations.iter_mut() {
- if let Some((field_name, field)) = find_field_for_block(fields, block_type) {
+ for (field_name, field) in fields.iter() {
+ if !field_matches_block(&field.config, block_type) {
+ continue;
+ }
*seen_fields.entry(field_name.clone()).or_insert(0) += 1;
let raw = raw_types.contains(block_type);
- apply_field_value(destination, &field_name, &field.config, value, raw, role, block_type)?;
+ apply_field_value(destination, field_name, &field.config, value, raw, role, block_type)?;
matched = true;
- break;
}
}
@@ -140,27 +116,20 @@ impl Message {
}
}
-fn find_field_for_block<'a>(
- fields: &'a IndexMap<String, Field>,
+fn field_matches_block(
+ config: &FieldConfig,
block_type: &ChatContentBlockType,
-) -> Option<(String, &'a Field)> {
- fields.iter().find_map(|(name, field)| {
- let matches = match &field.config {
- FieldConfig::Unique {
- block,
- ..
- } => block == block_type,
- FieldConfig::Collected {
- blocks,
- ..
- } => blocks.contains(block_type),
- };
- if matches {
- Some((name.clone(), field))
- } else {
- None
- }
- })
+) -> bool {
+ match config {
+ FieldConfig::Unique {
+ block,
+ ..
+ } => block == block_type,
+ FieldConfig::Collected {
+ blocks,
+ ..
+ } => blocks.contains(block_type),
+ }
}
fn apply_field_value(
diff --git a/crates/legacy/hanashi/src/chat/hanashi/renderer/mod.rs b/crates/legacy/hanashi/src/chat/hanashi/renderer/mod.rs
index 4302999c5..ba2903e26 100644
--- a/crates/legacy/hanashi/src/chat/hanashi/renderer/mod.rs
+++ b/crates/legacy/hanashi/src/chat/hanashi/renderer/mod.rs
@@ -211,4 +211,78 @@ mod tests {
assert_eq!(without_block, with_default_block);
}
+
+ #[test]
+ fn qwen38_preserves_historical_thinking_by_default() {
+ let renderer = renderer(HanashiConfig::Qwen38);
+
+ let history = vec![
+ user_message(),
+ ChatMessage::assistant().with_reasoning("deep thought".to_string()).with_text("the answer".to_string()),
+ user_message(),
+ ];
+ let prompt = render(&renderer, history);
+
+ assert!(prompt.contains("<think>\ndeep thought\n</think>"), "historical thinking dropped: {prompt:?}");
+ }
+
+ #[test]
+ fn qwen38_every_supported_effort_renders() {
+ let renderer = renderer(HanashiConfig::Qwen38);
+
+ for effort in [
+ ReasoningEffort::Disabled,
+ ReasoningEffort::Default,
+ ReasoningEffort::Low,
+ ReasoningEffort::Medium,
+ ReasoningEffort::XHigh,
+ ] {
+ render(&renderer, vec![system_message_with_effort(effort), user_message()]);
+ }
+ }
+
+ #[test]
+ fn qwen38_reasoning_effort_injects_instructions() {
+ let renderer = renderer(HanashiConfig::Qwen38);
+
+ let low = render(&renderer, vec![system_message_with_effort(ReasoningEffort::Low), user_message()]);
+ let medium = render(&renderer, vec![system_message_with_effort(ReasoningEffort::Medium), user_message()]);
+ let xhigh = render(&renderer, vec![system_message_with_effort(ReasoningEffort::XHigh), user_message()]);
+ let default = render(&renderer, vec![system_message_with_effort(ReasoningEffort::Default), user_message()]);
+
+ assert!(low.contains("Reasoning effort is set to low."), "got: {low:?}");
+ assert!(!medium.contains("Reasoning effort is set to"), "got: {medium:?}");
+ assert!(xhigh.contains("Reasoning effort is set to xhigh."), "got: {xhigh:?}");
+ assert_eq!(default, xhigh);
+ }
+
+ #[test]
+ fn qwen38_disabled_still_disables_thinking() {
+ let renderer = renderer(HanashiConfig::Qwen38);
+
+ let prompt = render(&renderer, vec![system_message_with_effort(ReasoningEffort::Disabled), user_message()]);
+
+ assert!(
+ prompt.ends_with("<|im_start|>assistant\n<think>\n\n</think>\n\n"),
+ "expected a thinking-disabled generation prompt, got: {prompt:?}"
+ );
+ }
+
+ #[test]
+ fn qwen38_capabilities_report_levels() {
+ let capabilities = HanashiConfig::Qwen38.capabilities().unwrap();
+
+ assert!(capabilities.supports_reasoning);
+ assert!(capabilities.supports_disable_reasoning);
+ for effort in [
+ ReasoningEffort::Disabled,
+ ReasoningEffort::Default,
+ ReasoningEffort::Low,
+ ReasoningEffort::Medium,
+ ReasoningEffort::XHigh,
+ ] {
+ assert!(capabilities.reasoning_efforts.contains(&effort), "missing {effort}");
+ }
+ assert!(!capabilities.reasoning_efforts.contains(&ReasoningEffort::High));
+ }
}
diff --git a/crates/legacy/hanashi/src/chat/harmony/config.rs b/crates/legacy/hanashi/src/chat/harmony/config.rs
index a16fb9683..5d079c245 100644
--- a/crates/legacy/hanashi/src/chat/harmony/config.rs
+++ b/crates/legacy/hanashi/src/chat/harmony/config.rs
@@ -14,6 +14,7 @@ impl HarmonyConfig {
HarmonyConfig::GptOss => ChatModelCapabilities {
supports_reasoning: true,
supports_disable_reasoning: false,
+ reasoning_efforts: vec![],
supports_tools: true,
supports_multiple_tool_calls: false,
requires_tools: false,
diff --git a/crates/legacy/mock-registry/src/model.rs b/crates/legacy/mock-registry/src/model.rs
index 66b2bec65..8b59bdca0 100644
--- a/crates/legacy/mock-registry/src/model.rs
+++ b/crates/legacy/mock-registry/src/model.rs
@@ -44,6 +44,6 @@ pub fn mock_model(
files: files.iter().map(|served_file| served_file.file.clone()).collect(),
},
},
- encodings: vec![],
+ encoding: None,
}
}
diff --git a/crates/legacy/nagare/src/chat/mod.rs b/crates/legacy/nagare/src/chat/mod.rs
index ae912d6e9..89a12ffef 100644
--- a/crates/legacy/nagare/src/chat/mod.rs
+++ b/crates/legacy/nagare/src/chat/mod.rs
@@ -20,7 +20,7 @@ use shoji::{
backend::chat_message::{Output as BackendOutput, ToolCallState},
},
types::{
- basic::{CancelToken, ToolCall, ToolDescription, ToolNamespace, Value, parse_lenient_json},
+ basic::{CancelToken, SamplingParameters, ToolCall, ToolDescription, ToolNamespace, Value, parse_lenient_json},
model::Model,
session::chat::{
ChatConfig, ChatContentBlock, ChatMessage, ChatReply, ChatReplyConfig, ChatReplyFinishReason,
@@ -115,6 +115,13 @@ impl Instance {
Instance::Message(session) => session.supports_multiple_tool_calls(),
}
}
+
+ pub fn sampling_defaults(&self) -> Option<SamplingParameters> {
+ match self {
+ Instance::Token(session) => Some(session.sampling_defaults()),
+ Instance::Message(_) => None,
+ }
+ }
}
#[bindings::export(Class)]
@@ -567,6 +574,11 @@ impl ChatSession {
self.tool_registry.is_some()
}
+ #[bindings::export(Method(Getter))]
+ pub async fn sampling_defaults(&self) -> Option<SamplingParameters> {
+ self.instance.lock().await.sampling_defaults()
+ }
+
#[bindings::export(Method)]
pub async fn reset(&self) -> Result<(), ChatSessionError> {
{
diff --git a/crates/legacy/nagare/src/chat/token.rs b/crates/legacy/nagare/src/chat/token.rs
index a0f380a6a..cc43418b8 100644
--- a/crates/legacy/nagare/src/chat/token.rs
+++ b/crates/legacy/nagare/src/chat/token.rs
@@ -1,5 +1,4 @@
use std::{
- io,
pin::Pin,
sync::Arc,
time::{Duration, Instant},
@@ -22,7 +21,7 @@ use shoji::{
},
},
types::{
- basic::TokenId,
+ basic::{SamplingParameters, TokenId},
model::Model,
session::chat::{
ChatConfig, ChatContentBlock, ChatMessage, ChatReplyConfig, ChatReplyFinishReason,
@@ -63,29 +62,15 @@ impl Session {
reference: String,
model: &Model,
) -> Result<Self, ChatSessionError> {
- let encoding_configs = model
- .encodings
- .iter()
- .map(|value| serde_json::from_str::<EncodingConfig>(value.json.as_str()).map_err(io::Error::other))
- .collect::<Result<Vec<_>, _>>()
- .map_err(|err| ChatSessionError::Loading {
- message: format!("Failed to parse encoding config: {err}"),
+ let encoding_config: Option<EncodingConfig> = model
+ .encoding
+ .as_ref()
+ .map(|value| serde_json::from_str::<EncodingConfig>(value.json.as_str()))
+ .transpose()
+ .map_err(|error| ChatSessionError::Loading {
+ message: format!("Failed to parse encoding config: {error}"),
})?;
- let encoding_config: Option<EncodingConfig> = if encoding_configs.is_empty() {
- None
- } else if encoding_configs.len() == 1 {
- encoding_configs.first().cloned()
- } else {
- let harmony_config =
- encoding_configs.iter().find(|config| matches!(config, EncodingConfig::Harmony { .. }));
- if harmony_config.is_some() {
- harmony_config.cloned()
- } else {
- encoding_configs.first().cloned()
- }
- };
-
let tokenizer_location = TokenizerLocation::Directory {
path: reference,
name: None,
@@ -339,6 +324,10 @@ impl Session {
pub fn supports_multiple_tool_calls(&self) -> bool {
self.encoding.supports_multiple_tool_calls()
}
+
+ pub fn sampling_defaults(&self) -> SamplingParameters {
+ self.instance.sampling_defaults()
+ }
}
struct StreamingState<'a> {
diff --git a/crates/legacy/shoji/src/traits/backend/chat_token.rs b/crates/legacy/shoji/src/traits/backend/chat_token.rs
index f77d28f89..7b8632bf7 100644
--- a/crates/legacy/shoji/src/traits/backend/chat_token.rs
+++ b/crates/legacy/shoji/src/traits/backend/chat_token.rs
@@ -4,7 +4,10 @@ use tokenizers::Tokenizer;
use crate::{
traits::backend::{Error, Instance as InstanceTrait},
- types::session::chat::{ChatConfig, ChatReplyConfig},
+ types::{
+ basic::SamplingParameters,
+ session::chat::{ChatConfig, ChatReplyConfig},
+ },
};
pub enum TokenStreamOutput {
@@ -47,4 +50,6 @@ pub trait Instance:
fn max_context_length(&self) -> Option<usize>;
fn stop_token_ids(&self) -> Option<Box<[u64]>>;
+
+ fn sampling_defaults(&self) -> SamplingParameters;
}
diff --git a/crates/legacy/shoji/src/types/basic/mod.rs b/crates/legacy/shoji/src/types/basic/mod.rs
index 36f5eeda2..ac520130e 100644
--- a/crates/legacy/shoji/src/types/basic/mod.rs
+++ b/crates/legacy/shoji/src/types/basic/mod.rs
@@ -10,6 +10,7 @@ mod pcm_batch;
mod reasoning_effort;
mod repository;
mod sampling_method;
+mod sampling_parameters;
mod sampling_policy;
mod sampling_seed;
mod token;
@@ -32,6 +33,7 @@ pub use pcm_batch::PcmBatch;
pub use reasoning_effort::ReasoningEffort;
pub use repository::Repository;
pub use sampling_method::SamplingMethod;
+pub use sampling_parameters::SamplingParameters;
pub use sampling_policy::SamplingPolicy;
pub use sampling_seed::SamplingSeed;
pub use token::{Token, TokenId, TokenValue};
diff --git a/crates/legacy/shoji/src/types/basic/reasoning_effort.rs b/crates/legacy/shoji/src/types/basic/reasoning_effort.rs
index 6b8e75725..1b9b6c89c 100644
--- a/crates/legacy/shoji/src/types/basic/reasoning_effort.rs
+++ b/crates/legacy/shoji/src/types/basic/reasoning_effort.rs
@@ -13,6 +13,7 @@ pub enum ReasoningEffort {
Low,
Medium,
High,
+ XHigh,
}
impl FromStr for ReasoningEffort {
@@ -25,6 +26,7 @@ impl FromStr for ReasoningEffort {
"low" => Ok(ReasoningEffort::Low),
"medium" => Ok(ReasoningEffort::Medium),
"high" => Ok(ReasoningEffort::High),
+ "xhigh" => Ok(ReasoningEffort::XHigh),
other => Err(format!("Unknown reasoning effort: {other}")),
}
}
@@ -41,6 +43,7 @@ impl Display for ReasoningEffort {
ReasoningEffort::Low => "low",
ReasoningEffort::Medium => "medium",
ReasoningEffort::High => "high",
+ ReasoningEffort::XHigh => "xhigh",
};
write!(formatter, "{name}")
}
diff --git a/crates/legacy/shoji/src/types/basic/sampling_parameters.rs b/crates/legacy/shoji/src/types/basic/sampling_parameters.rs
new file mode 100644
index 000000000..25004aaee
--- /dev/null
+++ b/crates/legacy/shoji/src/types/basic/sampling_parameters.rs
@@ -0,0 +1,12 @@
+use serde::{Deserialize, Serialize};
+
+#[bindings::export(Structure(Class))]
+#[derive(Debug, Clone, Copy, PartialEq, Default, Serialize, Deserialize)]
+pub struct SamplingParameters {
+ pub temperature: Option<f64>,
+ pub top_k: Option<i64>,
+ pub top_p: Option<f64>,
+ pub min_p: Option<f64>,
+ pub repetition_penalty: Option<f64>,
+ pub suffix_repetition_length: Option<i64>,
+}
diff --git a/crates/legacy/shoji/src/types/model/model.rs b/crates/legacy/shoji/src/types/model/model.rs
index 1f5413cfc..31fa14c3a 100644
--- a/crates/legacy/shoji/src/types/model/model.rs
+++ b/crates/legacy/shoji/src/types/model/model.rs
@@ -22,7 +22,7 @@ pub struct Model {
pub specializations: Vec<ModelSpecialization>,
pub accessibility: ModelAccessibility,
#[serde(default)]
- pub encodings: Vec<Value>,
+ pub encoding: Option<Value>,
}
#[bindings::export(Implementation)]
@@ -186,7 +186,7 @@ impl Model {
backend_version: String,
specializations: Vec<ModelSpecialization>,
accessibility: ModelAccessibility,
- encodings: Vec<Value>,
+ encoding: Option<Value>,
) -> Self {
let registry = ModelRegistry {
identifier: registry_identifier,
@@ -206,7 +206,7 @@ impl Model {
quantization: None,
specializations,
accessibility,
- encodings,
+ encoding,
}
}
}
diff --git a/crates/legacy/shoji/src/types/session/chat/capabilities.rs b/crates/legacy/shoji/src/types/session/chat/capabilities.rs
index aa6ab4ff6..a73647708 100644
--- a/crates/legacy/shoji/src/types/session/chat/capabilities.rs
+++ b/crates/legacy/shoji/src/types/session/chat/capabilities.rs
@@ -1,10 +1,14 @@
use serde::{Deserialize, Serialize};
+use crate::types::basic::ReasoningEffort;
+
#[bindings::export(Structure(Class))]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ChatModelCapabilities {
pub supports_reasoning: bool,
pub supports_disable_reasoning: bool,
+ #[serde(default)]
+ pub reasoning_efforts: Vec<ReasoningEffort>,
pub supports_tools: bool,
pub supports_multiple_tool_calls: bool,
pub requires_tools: bool,
diff --git a/crates/legacy/uzu/Cargo.toml b/crates/legacy/uzu/Cargo.toml
index f927a9f14..3317e73d2 100644
--- a/crates/legacy/uzu/Cargo.toml
+++ b/crates/legacy/uzu/Cargo.toml
@@ -79,6 +79,7 @@ tsify = { workspace = true, optional = true }
[target.'cfg(not(target_family = "wasm"))'.dependencies]
backend-remote.workspace = true
nagare.workspace = true
+hanashi.workspace = true
download-manager.workspace = true
rodio.workspace = true
serde.workspace = true
diff --git a/crates/legacy/uzu/src/engine/bridge/chat_token_backend.rs b/crates/legacy/uzu/src/engine/bridge/chat_token_backend.rs
index f310778e4..bef9955f7 100644
--- a/crates/legacy/uzu/src/engine/bridge/chat_token_backend.rs
+++ b/crates/legacy/uzu/src/engine/bridge/chat_token_backend.rs
@@ -20,7 +20,7 @@ use shoji::{
},
},
types::{
- basic::SamplingSeed,
+ basic::{SamplingParameters, SamplingSeed},
session::chat::{ChatConfig, ChatReplyConfig},
},
};
@@ -49,6 +49,7 @@ pub struct UzuChatTokenBackendInstance<B: Backend> {
config: ChatConfig,
stop_token_ids: Vec<i32>,
max_context_length: Option<u32>,
+ sampling_defaults: SamplingParameters,
#[cfg(feature = "capability-grammar")]
grammar_trigger_token_sequence: Option<Vec<u64>>,
}
@@ -62,7 +63,16 @@ impl<B: Backend> UzuChatTokenBackendInstance<B> {
let model_path = PathBuf::from(model_path);
let model = engine.load_language_model(&model_path).map_err(|err| err.to_string())?;
- let stop_token_ids = model.generation_config().stop_token_ids.iter().map(|id| *id as i32).collect();
+ let generation_config = model.generation_config();
+ let stop_token_ids = generation_config.stop_token_ids.iter().map(|id| *id as i32).collect();
+ let sampling_defaults = SamplingParameters {
+ temperature: generation_config.temperature.map(|value| value as f64),
+ top_k: generation_config.top_k.map(|value| value as i64),
+ top_p: generation_config.top_p.map(|value| value as f64),
+ min_p: generation_config.min_p.map(|value| value as f64),
+ repetition_penalty: generation_config.repetition_penalty.map(|value| value as f64),
+ suffix_repetition_length: generation_config.suffix_repetition_length.map(|value| value as i64),
+ };
let max_context_length = get_max_context_length(&model, config.context_length.clone());
#[cfg(feature = "capability-grammar")]
let grammar_trigger_token_sequence = grammar_trigger_token_sequence(&model);
@@ -73,6 +83,7 @@ impl<B: Backend> UzuChatTokenBackendInstance<B> {
config,
stop_token_ids,
max_context_length,
+ sampling_defaults,
#[cfg(feature = "capability-grammar")]
grammar_trigger_token_sequence,
})
@@ -190,6 +201,10 @@ impl<B: Backend> ChatTokenBackendInstance for UzuChatTokenBackendInstance<B> {
fn stop_token_ids(&self) -> Option<Box<[u64]>> {
Some(self.stop_token_ids.iter().map(|id| *id as u64).collect())
}
+
+ fn sampling_defaults(&self) -> SamplingParameters {
+ self.sampling_defaults
+ }
}
// Horrible code
diff --git a/crates/legacy/uzu/src/registry/local/mod.rs b/crates/legacy/uzu/src/registry/local/mod.rs
index aff95c3fd..15c0842c2 100644
--- a/crates/legacy/uzu/src/registry/local/mod.rs
+++ b/crates/legacy/uzu/src/registry/local/mod.rs
@@ -3,6 +3,7 @@ mod config;
use std::{fs, future::Future, path::Path, pin::Pin};
pub use config::Config;
+use hanashi::chat::EncodingConfig;
use shoji::{
traits::Registry as RegistryTrait,
types::{
@@ -102,22 +103,23 @@ impl Registry {
path: path.to_string_lossy().to_string(),
},
},
- load_encodings(&path),
+ load_encoding(&path),
)
}
}
-fn load_encodings(model_path: &Path) -> Vec<Value> {
+fn load_encoding(model_path: &Path) -> Option<Value> {
let Ok(text) = fs::read_to_string(model_path.join("encoding.json")) else {
- return vec![];
+ return None;
};
let parsed = serde_json::from_str::<serde_json::Value>(&text);
- match parsed {
+ let encodings: Vec<Value> = match parsed {
Ok(serde_json::Value::Array(entries)) => entries.into_iter().map(Value::from).collect(),
Ok(entry) => vec![Value::from(entry)],
Err(error) => {
tracing::warn!(?error, path = %model_path.display(), "ignoring invalid encoding.json");
vec![]
},
- }
+ };
+ EncodingConfig::select(&encodings)
}
diff --git a/crates/legacy/uzu/src/registry/mirai/types.rs b/crates/legacy/uzu/src/registry/mirai/types.rs
index f69554ee6..3e5d6483c 100644
--- a/crates/legacy/uzu/src/registry/mirai/types.rs
+++ b/crates/legacy/uzu/src/registry/mirai/types.rs
@@ -1,4 +1,5 @@
-use serde::{Deserialize, Serialize};
+use hanashi::chat::EncodingConfig;
+use serde::{Deserialize, Deserializer, Serialize};
use shoji::types::{
basic::{Metadata, Value},
model::{
@@ -160,7 +161,13 @@ pub struct ResponseModel {
pub quantization: Option<Quantization>,
pub specializations: Vec<ModelSpecialization>,
pub accessibility: ModelAccessibility,
- pub encodings: Vec<Value>,
+ #[serde(rename = "encodings", default, deserialize_with = "deserialize_encoding")]
+ pub encoding: Option<Value>,
+}
+
+fn deserialize_encoding<'de, D: Deserializer<'de>>(deserializer: D) -> Result<Option<Value>, D::Error> {
+ let encodings = Vec::<Value>::deserialize(deserializer)?;
+ Ok(EncodingConfig::select(&encodings))
}
impl ResponseModel {
@@ -194,7 +201,7 @@ impl ResponseModel {
quantization,
specializations: self.specializations.clone(),
accessibility: self.accessibility.clone(),
- encodings: self.encodings.clone(),
+ encoding: self.encoding.clone(),
})
}
}
diff --git a/crates/legacy/uzu/src/registry/openai/mod.rs b/crates/legacy/uzu/src/registry/openai/mod.rs
index e8d054851..dbd74293f 100644
--- a/crates/legacy/uzu/src/registry/openai/mod.rs
+++ b/crates/legacy/uzu/src/registry/openai/mod.rs
@@ -98,7 +98,7 @@ impl RegistryTrait for Registry {
ModelAccessibility::Remote {
repository: None,
},
- vec![],
+ None,
)
})
.collect();
diff --git a/crates/legacy/uzu/src/storage/types/crc_snapshot.rs b/crates/legacy/uzu/src/storage/types/crc_snapshot.rs
deleted file mode 100644
index 891707c7f..000000000
--- a/crates/legacy/uzu/src/storage/types/crc_snapshot.rs
+++ /dev/null
@@ -1,27 +0,0 @@
-use std::{fs::remove_file, path::Path};
-
-use crate::storage::StorageError;
-
-pub struct CrcSnapshot;
-
-impl CrcSnapshot {
- fn crc_file_path(
- model_dir: &Path,
- filename: &str,
- ) -> std::path::PathBuf {
- model_dir.join(format!("{}.crc", filename))
- }
-
- pub fn remove_crc(
- model_dir: &Path,
- filename: &str,
- ) -> Result<(), StorageError> {
- let crc_path = Self::crc_file_path(model_dir, filename);
- if crc_path.exists() {
- remove_file(&crc_path).map_err(|error| StorageError::IO {
- message: error.to_string(),
- })?;
- }
- Ok(())
- }
-}
diff --git a/crates/legacy/uzu/src/storage/types/mod.rs b/crates/legacy/uzu/src/storage/types/mod.rs
index 75ff9ea90..30dae366c 100644
--- a/crates/legacy/uzu/src/storage/types/mod.rs
+++ b/crates/legacy/uzu/src/storage/types/mod.rs
@@ -1,9 +1,7 @@
-mod crc_snapshot;
mod download_phase;
mod download_state;
mod item;
-pub use crc_snapshot::CrcSnapshot;
pub use download_phase::DownloadPhase;
pub use download_state::{DownloadState, reduce_file_download_states};
pub use item::Item;