From 68a7d673e694c5d85a6984b6745d38d7a508d644 Mon Sep 17 00:00:00 2001 From: Fumito Ito Date: Fri, 1 Nov 2024 06:14:09 +0900 Subject: [PATCH] publish some needed interfaces --- Sources/AnthropicSwiftSDK/Entity/Content.swift | 4 ++-- Sources/AnthropicSwiftSDK/Entity/ToolResultContent.swift | 6 ++++++ .../Network/Extension/StreamingResponse+Extension.swift | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Sources/AnthropicSwiftSDK/Entity/Content.swift b/Sources/AnthropicSwiftSDK/Entity/Content.swift index c1c81c0..65e98a6 100644 --- a/Sources/AnthropicSwiftSDK/Entity/Content.swift +++ b/Sources/AnthropicSwiftSDK/Entity/Content.swift @@ -8,7 +8,7 @@ import Foundation /// Type of content block. -enum ContentType: String { +public enum ContentType: String { /// single string case text /// image content @@ -33,7 +33,7 @@ public enum Content { case toolResult(ToolResultContent) /// The type of content block. - var contentType: ContentType { + public var contentType: ContentType { switch self { case .text: return ContentType.text diff --git a/Sources/AnthropicSwiftSDK/Entity/ToolResultContent.swift b/Sources/AnthropicSwiftSDK/Entity/ToolResultContent.swift index 29dd5c1..f2cc40f 100644 --- a/Sources/AnthropicSwiftSDK/Entity/ToolResultContent.swift +++ b/Sources/AnthropicSwiftSDK/Entity/ToolResultContent.swift @@ -16,6 +16,12 @@ public struct ToolResultContent { public let content: [Content] /// Set to `true` if the tool execution resulted in an error. public let isError: Bool? + + public init(toolUseId: String, content: [Content], isError: Bool?) { + self.toolUseId = toolUseId + self.content = content + self.isError = isError + } } extension ToolResultContent: Encodable {} diff --git a/Sources/AnthropicSwiftSDK/Network/Extension/StreamingResponse+Extension.swift b/Sources/AnthropicSwiftSDK/Network/Extension/StreamingResponse+Extension.swift index db295fc..899bd00 100644 --- a/Sources/AnthropicSwiftSDK/Network/Extension/StreamingResponse+Extension.swift +++ b/Sources/AnthropicSwiftSDK/Network/Extension/StreamingResponse+Extension.swift @@ -7,7 +7,7 @@ extension StreamingResponse { /// True if `stop_reason` of this StreamingResponse is `tool_use` - var isToolUse: Bool { + public var isToolUse: Bool { switch self { case let deltaResponse as StreamingMessageDeltaResponse: return deltaResponse.isToolUse