Skip to content

Commit

Permalink
remove oslog
Browse files Browse the repository at this point in the history
  • Loading branch information
maerki committed Aug 22, 2024
1 parent 5b8da1b commit 7e80a19
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
1 change: 0 additions & 1 deletion Sources/OpenAIClient/Core/Client+Initialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import OpenAPIRuntime
import Foundation
import OpenAPIURLSession
import HTTPTypes
import OSLog

public extension Client {
init(key: String, beta: Bool = true) throws {
Expand Down
1 change: 0 additions & 1 deletion Sources/OpenAIClient/Core/ClientMiddlewares.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import OpenAPIRuntime
import Foundation
import OpenAPIURLSession
import HTTPTypes
import OSLog


internal struct AuthMiddleware: ClientMiddleware {
Expand Down
20 changes: 9 additions & 11 deletions Tests/OpenAIClientTests/AssistantsTests.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import XCTest
@testable import OpenAIClient
import OpenAPIRuntime
import OSLog


final class AssistantsTests: XCTestCase {

var client: Client!
let Log = Logger(subsystem: "Tests", category: "Assistants")
let api_key = ProcessInfo.processInfo.environment["OPENAI_KEY"]!
let assistant_id = ProcessInfo.processInfo.environment["ASSISTANT_ID"]!

Expand All @@ -33,11 +31,11 @@ final class AssistantsTests: XCTestCase {
for content in message.content {
switch content {
case .MessageContentImageFileObject(let imageFile):
Log.info("Image File: \(imageFile.image_file.file_id)")
print("Image File: \(imageFile.image_file.file_id)")
case .MessageContentImageUrlObject(let imageUrl):
Log.info("Image URL: \(imageUrl.image_url.url)")
print("Image URL: \(imageUrl.image_url.url)")
case .MessageContentTextObject(let text):
Log.info(("Text: \(text.text.value)"))
print(("Text: \(text.text.value)"))
}
}
}
Expand All @@ -57,17 +55,17 @@ final class AssistantsTests: XCTestCase {
let eventData = try JSONDecoder().decode(Components.Schemas.RunStreamEvent.self, from: data)
switch eventData {
case .RunObject(_):
Log.debug("Received RunObject")
print("Received RunObject")
case .RunStepObject(_):
Log.debug("Received RunStepObject")
print("Received RunStepObject")
case .RunStepDeltaObject(_):
Log.debug("Received RunStepDeltaObject")
print("Received RunStepDeltaObject")
case .MessageObject(_):
Log.debug("Received MessageObject")
print("Received MessageObject")
case .MessageDeltaObject(_):
Log.debug("Received MessageDeltaObject")
print("Received MessageDeltaObject")
case .case6(_):
Log.debug("Received Case6")
print("Received Case6")
}

}
Expand Down
10 changes: 4 additions & 6 deletions Tests/OpenAIClientTests/WrapperTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@

import XCTest
@testable import OpenAIClient
import OSLog

final class WrapperTests: XCTestCase {

var client: Client!
let Log = Logger(subsystem: "Tests", category: "Assistants")
let api_key = ProcessInfo.processInfo.environment["OPENAI_KEY"]!
let assistant_id = ProcessInfo.processInfo.environment["ASSISTANT_ID"]!

Expand All @@ -27,7 +25,7 @@ final class WrapperTests: XCTestCase {
let messages = try await thread.run()
for message in messages {
let text = try message.text
Log.info("Message: \(text)")
print("Message: \(text)")
}
}

Expand All @@ -41,20 +39,20 @@ final class WrapperTests: XCTestCase {
let greeting: String
}
let object = try message.decoded(as: Greeting.self)
Log.info("Message: \(object.greeting)")
print("Message: \(object.greeting)")
}
}

func testChat() async throws {
let chat = Chat(using: client)
let response = try await chat.completion("Wer bist du?").text
Log.info("\(response)")
print("\(response)")
}

func testImageUpload() async throws {
let image = UIImage(systemName: "figure.sailing")!
let file = try await File.upload(image.pngData()!, purpose: .assistants, using: client)
Log.info("File created: \(file.id)")
print("File created: \(file.id)")
}


Expand Down

0 comments on commit 7e80a19

Please sign in to comment.