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
23 changes: 18 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,16 @@ jobs:

build_and_test_linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- image: swift:6.0.1-jammy
dependencies: locked
- image: swift:6.2-jammy
dependencies: latest
container:
image: swift:6.0.1-jammy
image: ${{ matrix.image }}
steps:
- name: Install dependencies
run: |
Expand All @@ -33,10 +41,15 @@ jobs:
- uses: actions/checkout@v4
- name: Get swift version
run: swift --version
- name: Build
run: swift build -q
- name: Resolve current compatible dependencies
if: matrix.dependencies == 'latest'
run: swift package update
- name: Clean build
run: |
swift package clean
swift build -q --force-resolved-versions
- name: Run tests
run: swift test -q
run: swift test -q --force-resolved-versions

lint:
runs-on: macos-latest
Expand All @@ -48,4 +61,4 @@ jobs:
- name: Install swiftformat
run: brew install swiftformat
- name: Check formatting
run: swiftformat --config rules.swiftformat --lint .
run: swiftformat --config rules.swiftformat --lint .
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ struct ChatDisplayMessageView: View {
case .content(let content):
let text = content.compactMap { contentItem -> String? in
if case .text(let text) = contentItem {
return text
text
} else {
return nil
nil
}
}.first ?? ""

let urls = content.compactMap { contentItem -> URL? in
if case .imageUrl(let imageDetail) = contentItem {
return imageDetail.url
imageDetail.url
} else {
return nil
nil
}
}
VStack(alignment: .leading, spacing: 8) {
Expand Down
4 changes: 4 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.25.2"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.78.0"),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
Expand All @@ -26,6 +27,9 @@ let package = Package(
name: "SwiftOpenAI",
dependencies: [
.product(name: "AsyncHTTPClient", package: "async-http-client", condition: .when(platforms: [.linux])),
.product(name: "NIOCore", package: "swift-nio", condition: .when(platforms: [.linux])),
.product(name: "NIOFoundationCompat", package: "swift-nio", condition: .when(platforms: [.linux])),
.product(name: "NIOHTTP1", package: "swift-nio", condition: .when(platforms: [.linux])),
]),
.testTarget(
name: "SwiftOpenAITests",
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAI/Private/Audio/AudioUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ nonisolated private func isBuiltInHeadphonePort(deviceID: AudioDeviceID) -> Bool
mElement: kAudioObjectPropertyElementMain)

let err = withUnsafeMutablePointer(to: &deviceUID) { ptr -> OSStatus in
return AudioObjectGetPropertyData(
AudioObjectGetPropertyData(
deviceID,
&address,
0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,17 @@ public struct ResponseModel: Decodable {
let outputTextItems = output.compactMap { outputItem -> String? in
switch outputItem {
case .message(let message):
return message.content.compactMap { contentItem -> String? in
message.content.compactMap { contentItem -> String? in
switch contentItem {
case .outputText(let outputText):
return outputText.text
outputText.text
case .refusal:
return nil
nil
}
}.joined()

default:
return nil
nil
}
}

Expand Down
Loading