Im creating a simple chatbox using an api caller library I created and imported but it looks like Xcode is not recognizing the modules as I get multiple "no member" errors for the 'ChatClient' module.
`import SwiftUI import openaiLibrary
final class ViewModel: ObservableObject { private var openAI: openaiLibrary.ChatClient
init(apiKey: String) {
let config = openaiLibrary.ChatClient.OpenAIEndpointProvider.makeDefaultKey(api_key: apiKey, endpointProvider: openaiLibrary.ChatClient.OpenAIEndpointProvider())
self.openAI = openaiLibrary.ChatClient(apiKey: apiKey, openaiEndpoint: config.baseURL)
}
public func sendAIRequest(with search: String, completion: @escaping(Result<String,Error>) -> Void) {
openAI?.sendCompletion(with: search) { result in
switch result {
case .success(let response):
if let text = response.choices.first?.text {
completion(.success(text))
} else {
completion(.failure(NSError(domain: "error", code: 1, userInfo: [NSLocalizedDescriptionKey: "No response found"])))
}
case .failure(let error):
completion(.failure(error))
}
}
}
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
}
}
#Preview {
ContentView()
}
}
` I can also provide my source code for my api caller that my openaiLibrary package dependency uses to make sure everything is defined correctly so that Xcode recognizes everything, due to character constraints I wasn't able to fit it in this post.