Make Tool.inputSchema nonoptional (#123)
This commit is contained in:
parent
c95d0c0354
commit
f3b9ba4a59
1 changed files with 14 additions and 11 deletions
|
|
@ -14,7 +14,7 @@ public struct Tool: Hashable, Codable, Sendable {
|
|||
/// The tool description
|
||||
public let description: String
|
||||
/// The tool input schema
|
||||
public let inputSchema: Value?
|
||||
public let inputSchema: Value
|
||||
|
||||
/// Annotations that provide display-facing and operational information for a Tool.
|
||||
///
|
||||
|
|
@ -86,7 +86,7 @@ public struct Tool: Hashable, Codable, Sendable {
|
|||
public init(
|
||||
name: String,
|
||||
description: String,
|
||||
inputSchema: Value? = nil,
|
||||
inputSchema: Value,
|
||||
annotations: Annotations = nil
|
||||
) {
|
||||
self.name = name
|
||||
|
|
@ -183,7 +183,7 @@ public struct Tool: Hashable, Codable, Sendable {
|
|||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
name = try container.decode(String.self, forKey: .name)
|
||||
description = try container.decode(String.self, forKey: .description)
|
||||
inputSchema = try container.decodeIfPresent(Value.self, forKey: .inputSchema)
|
||||
inputSchema = try container.decode(Value.self, forKey: .inputSchema)
|
||||
annotations =
|
||||
try container.decodeIfPresent(Tool.Annotations.self, forKey: .annotations) ?? .init()
|
||||
}
|
||||
|
|
@ -192,9 +192,7 @@ public struct Tool: Hashable, Codable, Sendable {
|
|||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(name, forKey: .name)
|
||||
try container.encode(description, forKey: .description)
|
||||
if let schema = inputSchema {
|
||||
try container.encode(schema, forKey: .inputSchema)
|
||||
}
|
||||
try container.encode(inputSchema, forKey: .inputSchema)
|
||||
if !annotations.isEmpty {
|
||||
try container.encode(annotations, forKey: .annotations)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue