Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .amazonq/rules/swift.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ struct AddingTwoNumbersTests {

}
```
When asked to write unit tests, always prefer the new Swift testing framework over XCTest.

Always use standard Swift 6 tools by preference. For example,
when asked to write unit tests, always prefer the new Swift testing framework over XCTest.
When asked to format files, use swift format instead of swift-format.

In general, prefer the use of Swift Concurrency (async/await,
actors, etc.) over tools like Dispatch or Combine, but if the
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run tests
- name: Build
run: swift build --configuration release
- name: Tests
run: swift test

soundness:
Expand Down
4 changes: 4 additions & 0 deletions Sources/BedrockModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
//
//===----------------------------------------------------------------------===//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

public struct BedrockModel: Hashable, Sendable, Equatable, RawRepresentable {
public var rawValue: String { id }
Expand Down
7 changes: 6 additions & 1 deletion Sources/BedrockService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@
@preconcurrency import AWSBedrockRuntime
import AWSClientRuntime
import AwsCommonRuntimeKit
import Foundation
import Logging

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

// for setenv and unsetenv functions
#if os(Linux)
import Glibc
Expand Down
4 changes: 4 additions & 0 deletions Sources/BedrockServiceError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
//
//===----------------------------------------------------------------------===//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

//TODO: split in two structs : BedrockModelError and BedrockLibraryError
public enum BedrockLibraryError: Error {
Expand Down
5 changes: 5 additions & 0 deletions Sources/Converse/BedrockService+Converse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@

@preconcurrency import AWSBedrockRuntime
import AwsCommonRuntimeKit

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

extension BedrockService {

Expand Down
5 changes: 5 additions & 0 deletions Sources/Converse/BedrockService+ConverseStreaming.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@

@preconcurrency import AWSBedrockRuntime
import AwsCommonRuntimeKit

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

extension BedrockService {

Expand Down
5 changes: 5 additions & 0 deletions Sources/Converse/ContentBlocks/Content.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
//===----------------------------------------------------------------------===//

@preconcurrency import AWSBedrockRuntime

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

public enum Content: Codable, CustomStringConvertible, Sendable {
case text(String)
Expand Down
5 changes: 5 additions & 0 deletions Sources/Converse/ContentBlocks/DocumentBlock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
//===----------------------------------------------------------------------===//

@preconcurrency import AWSBedrockRuntime

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

public struct DocumentBlock: Codable, Sendable {
public let name: String
Expand Down
7 changes: 6 additions & 1 deletion Sources/Converse/ContentBlocks/DocumentToJSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
//
//===----------------------------------------------------------------------===//

import Foundation
import Smithy

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

// FIXME: avoid extensions on structs you do not control
extension SmithyDocument {
public func toJSON() throws -> JSON {
Expand Down
5 changes: 5 additions & 0 deletions Sources/Converse/ContentBlocks/ImageBlock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
//===----------------------------------------------------------------------===//

@preconcurrency import AWSBedrockRuntime

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

public struct ImageBlock: Codable, Sendable {
public let format: Format
Expand Down
4 changes: 4 additions & 0 deletions Sources/Converse/ContentBlocks/JSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
//
//===----------------------------------------------------------------------===//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

public struct JSON: Codable, @unchecked Sendable { // FIXME: make Sendable
public var value: Any?
Expand Down
7 changes: 6 additions & 1 deletion Sources/Converse/ContentBlocks/JSONtoDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
//
//===----------------------------------------------------------------------===//

import Foundation
import Smithy

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

extension JSON {
public func toDocument() throws -> Document {
let encoder = JSONEncoder()
Expand Down
5 changes: 5 additions & 0 deletions Sources/Converse/ContentBlocks/ReasoningBlock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
//===----------------------------------------------------------------------===//

@preconcurrency import AWSBedrockRuntime

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

public struct EncryptedReasoning: Codable, Sendable {
public var reasoning: Data
Expand Down
5 changes: 5 additions & 0 deletions Sources/Converse/ContentBlocks/S3Location.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
//===----------------------------------------------------------------------===//

@preconcurrency import AWSBedrockRuntime

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

public struct S3Location: Codable, Sendable {
public let bucketOwner: String?
Expand Down
5 changes: 5 additions & 0 deletions Sources/Converse/ContentBlocks/ToolResultBlock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
//===----------------------------------------------------------------------===//

@preconcurrency import AWSBedrockRuntime

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

public struct ToolResultBlock: Codable, Sendable {
public let id: String
Expand Down
5 changes: 5 additions & 0 deletions Sources/Converse/ContentBlocks/ToolUseBlock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
//===----------------------------------------------------------------------===//

@preconcurrency import AWSBedrockRuntime

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

public struct ToolUseBlock: Codable, Sendable {
public let id: String
Expand Down
5 changes: 5 additions & 0 deletions Sources/Converse/ContentBlocks/VideoBlock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
//===----------------------------------------------------------------------===//

@preconcurrency import AWSBedrockRuntime

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

public struct VideoBlock: Codable, Sendable {
public let format: Format
Expand Down
7 changes: 6 additions & 1 deletion Sources/Converse/ConverseRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@
//===----------------------------------------------------------------------===//

@preconcurrency import AWSBedrockRuntime
import Foundation
import Smithy

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

public struct ConverseRequest {
let model: BedrockModel
let messages: [Message]
Expand Down
4 changes: 4 additions & 0 deletions Sources/Converse/ConverseRequestBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
//
//===----------------------------------------------------------------------===//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

public struct ConverseRequestBuilder {

Expand Down
5 changes: 5 additions & 0 deletions Sources/Converse/Message.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
//===----------------------------------------------------------------------===//

@preconcurrency import AWSBedrockRuntime

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

public struct Message: Codable, CustomStringConvertible, Sendable {

Expand Down
5 changes: 5 additions & 0 deletions Sources/Converse/Role.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
//===----------------------------------------------------------------------===//

@preconcurrency import AWSBedrockRuntime

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

public struct Role: Codable, Sendable, Equatable, CustomStringConvertible {
private enum RoleType: Codable, Sendable, Equatable {
Expand Down
7 changes: 6 additions & 1 deletion Sources/Converse/Streaming/ConverseReplyStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
//
//===----------------------------------------------------------------------===//
@preconcurrency import AWSBedrockRuntime
import Foundation
import Logging

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

public struct ConverseReplyStream: Sendable {

private let logger: Logger
Expand Down
7 changes: 6 additions & 1 deletion Sources/Converse/Tool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@
//===----------------------------------------------------------------------===//

@preconcurrency import AWSBedrockRuntime
import Foundation
import Smithy

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

public struct Tool: Codable, CustomStringConvertible {
public let name: String
public let inputSchema: JSON
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
//
//===----------------------------------------------------------------------===//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

extension BedrockService {

Expand Down
5 changes: 5 additions & 0 deletions Sources/InvokeModel/BedrockService+InvokeModelImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@

@preconcurrency import AWSBedrockRuntime
import AwsCommonRuntimeKit

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

extension BedrockService {

Expand Down
5 changes: 5 additions & 0 deletions Sources/InvokeModel/BedrockService+InvokeModelText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@

@preconcurrency import AWSBedrockRuntime
import AwsCommonRuntimeKit

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

extension BedrockService {

Expand Down
4 changes: 4 additions & 0 deletions Sources/InvokeModel/ContentType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
//
//===----------------------------------------------------------------------===//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

public enum ContentType {
case json
Expand Down
4 changes: 4 additions & 0 deletions Sources/InvokeModel/ImageGenerationOutput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
//
//===----------------------------------------------------------------------===//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

public struct ImageGenerationOutput: Codable {
public let images: [Data]
Expand Down
4 changes: 4 additions & 0 deletions Sources/InvokeModel/ImageResolution.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
//
//===----------------------------------------------------------------------===//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

public struct ImageResolution: Codable, Equatable, Sendable {
public let width: Int
Expand Down
Loading
Loading