Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use instance member 'key' within property initializer; property initializers run before 'self' is available #117

Open
abdalla-elnajjar opened this issue Sep 12, 2023 · 0 comments

Comments

@abdalla-elnajjar
Copy link

I am creating chatGPT clone for my study. I am using openAISwift to connect with openAI WebAPI. I have small issue creating config object

I applied you api change but still I have error

struct MainView: View {
    @State private var chatText :String  = ""
    @State private var answers :[String]  = []

    private let key: String = "sk-"
    var openAI: OpenAISwift = OpenAISwift(config: OpenAISwift.Config.makeDefaultOpenAI(apiKey: key))
    ...
}

error
Cannot use instance member 'key' within property initializer; property initializers run before 'self' is available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant