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

Swift 6 Support and Base URL Handling Update #38

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

1amageek
Copy link

This PR introduces updates to support Swift 6, including adjustments to concurrency-related features and the Sendable conformance across relevant types.

Swift 6 Compatibility:

Updated swift-tools-version to 6.0 in Package.swift.

Added Sendable conformance to various structs, enums, and classes in compliance with Swift 6’s stricter concurrency rules.

Refined baseURL Handling:

Modified OKRouter to require an explicit baseURL argument in the asURLRequest() method rather than relying on a static baseURL.
Refactored OllamaKit to store baseURL as an instance property, allowing more flexible and testable configurations.
Updated all API request functions to pass baseURL explicitly when creating URLRequest objects.

These updates help ensure compatibility with Swift 6 while making the base URL configuration more flexible and consistent.

@kevinhermawan
Copy link
Owner

Great work, @1amageek! Could you kindly explain its significance? Why do we need to make all types conform to Sendable? IMHO, the current code is working well in Swift 6.0. I’m eager to learn more about this concept. 😃

Additionally, could you please run the Playground application and verify that everything functions smoothly without any modifications required. Thanks!

@1amageek
Copy link
Author

Thank you for your insightful question and feedback!

Sendable in Swift 6:

  • Prevents data races
  • Enables thread-safety checks
  • Clear design intent
  • Future-proofs code

Current code works due to implicit conformance or non-concurrent usage

Explicit Sendable benefits:

  • Compile-time safety checks
  • Clear thread-safety documentation
  • Enables use in other concurrent contexts

I have already implemented it in my project, and it is working without any issues.

@kevinhermawan
Copy link
Owner

Hi @1amageek, could you please verify and fix the issues by running the Playground app?

Xcode 2024-10-25 05 54 43

@kevinhermawan
Copy link
Owner

Hey @1amageek, I’m happy for all your contributions! But I’m a bit bummed that changing the data type from Double to Float will break the implementation. This library is used in a lot of apps, so we should probably stick with Double.

Could we stick this PR (or create a new one) just for making OllamaKit conform to Sendable to avoid any unexpected issues?

@lukepistrol lukepistrol mentioned this pull request Nov 26, 2024
@1amageek
Copy link
Author

@kevinhermawan

Thank you always for your amazing work.
I am developing a Swift Agent using your repository.
It allows you to define Agents declaratively, similar to SwiftUI.
Please feel free to try it out if you're interested.

I am also using OllamaKit there.

https://github.com/1amageek/SwiftAgent

@kevinhermawan
Copy link
Owner

It looks like you have integrated swift-json-schema into this PR? That's awesome! I'll go check it out in my spare time!

@kevinhermawan
Copy link
Owner

@kevinhermawan

Thank you always for your amazing work. I am developing a Swift Agent using your repository. It allows you to define Agents declaratively, similar to SwiftUI. Please feel free to try it out if you're interested.

I am also using OllamaKit there.

https://github.com/1amageek/SwiftAgent

This is super cool! I’ll definitely check it out in my free time.

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

Successfully merging this pull request may close these issues.

2 participants