-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from fumito-ito/feature/pdf
PDF support
- Loading branch information
Showing
9 changed files
with
85 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
Sources/AnthropicSwiftSDK/Entity/Content/DocumentContent.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// DocumentContent.swift | ||
// AnthropicSwiftSDK | ||
// | ||
// Created by 伊藤史 on 2024/11/05. | ||
// | ||
import Foundation | ||
|
||
public struct DocumentContent { | ||
public enum DocumentContentType: String, Codable { | ||
case base64 | ||
} | ||
|
||
public enum DocumentContentMediaType: String, Codable { | ||
case pdf = "application/pdf" | ||
} | ||
|
||
public let type: DocumentContentType | ||
public let mediaType: DocumentContentMediaType | ||
public let data: Data | ||
|
||
public init(type: DocumentContentType, mediaType: DocumentContentMediaType, data: Data) { | ||
self.type = type | ||
self.mediaType = mediaType | ||
self.data = data | ||
} | ||
} | ||
|
||
extension DocumentContent: Codable { | ||
enum CodingKeys: String, CodingKey { | ||
case type | ||
case mediaType = "media_type" | ||
case data | ||
} | ||
|
||
public init(from decoder: any Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
self.type = try container.decode(DocumentContent.DocumentContentType.self, forKey: .type) | ||
self.mediaType = try container.decode(DocumentContent.DocumentContentMediaType.self, forKey: .mediaType) | ||
self.data = try container.decode(Data.self, forKey: .data) | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters