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

Issue with Swift on Linux #15

Closed
dfperry5 opened this issue Dec 30, 2022 · 1 comment
Closed

Issue with Swift on Linux #15

dfperry5 opened this issue Dec 30, 2022 · 1 comment

Comments

@dfperry5
Copy link
Contributor

dfperry5 commented Dec 30, 2022

Problem

When trying to use this package to build a lambda using the swift-aws-lambda runtime approach, there is a step where you need to build the executable using docker. When exciting this command:

docker run \                                                              ─╯
    --rm \
    --volume "$(pwd)/:/src" \
    --workdir "/src/" \
    swift:5.7.0-amazonlinux2 \
    swift build --product OpenAIPoc -c release -Xswiftc -static-stdlib

I'm seeing the below issue:

/src/.build/checkouts/OpenAISwift/Sources/OpenAISwift/OpenAISwift.swift:45:95: error: cannot find type 'URLRequest' in scope
    private func prepareRequest<BodyType: Encodable>(_ endpoint: Endpoint, body: BodyType) -> URLRequest {
                                                                                              ^~~~~~~~~~
/src/.build/checkouts/OpenAISwift/Sources/OpenAISwift/OpenAISwift.swift:28:34: error: type 'URLSession' (aka 'AnyObject') has no member 'shared'
        let session = URLSession.shared
                      ~~~~~~~~~~ ^~~~~~
/src/.build/checkouts/OpenAISwift/Sources/OpenAISwift/OpenAISwift.swift:48:23: error: cannot find 'URLRequest' in scope
        var request = URLRequest(url: urlComponents!.url!)
                      ^~~~~~~~~~

Potential Solution

By adding the below code to the OpenAI.swift - I think this problem would be alleviated.

#if canImport(FoundationNetworking) && canImport(FoundationXML)
import FoundationNetworking
import FoundationXML
#endif

Are you cool with me opening a PR to add this in?

Thanks!

@adamrushy
Copy link
Owner

Yeah, great idea and thanks for contributing! I shall get this merged after running Actions!

adamrushy added a commit that referenced this issue Jan 2, 2023
Addressing Issue: #15 - trying to use this library to run in Vapor / …
MarkHoath added a commit to MarkHoath/OpenAISwift that referenced this issue Feb 7, 2024
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

2 participants