Skip to content

Commit

Permalink
Fixed issues with string conversions and llama module import
Browse files Browse the repository at this point in the history
  • Loading branch information
srgtuszy committed Oct 15, 2024
1 parent c474fa2 commit d8f54eb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/build_library.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Library using Swift Package Manager
name: Build Library

on:
push:
Expand All @@ -7,8 +7,8 @@ on:

jobs:

build-and-test-linux:
name: Build and Test on Linux
build-linux:
name: Build on Linux
runs-on: ubuntu-latest
steps:
- name: Checkout Source Code
Expand All @@ -25,8 +25,8 @@ jobs:
- name: Build with Swift Package Manager
run: swift build

build-and-test-macos:
name: Build and Test on macOS
build-macos:
name: Build on macOS
runs-on: macos-latest
steps:
- name: Checkout Source Code
Expand All @@ -40,8 +40,8 @@ jobs:
-derivedDataPath DerivedData \
SWIFT_ACTIVE_COMPILATION_CONDITIONS=DEBUG
build-and-test-ios:
name: Build and Test on iOS
build-ios:
name: Build on iOS
runs-on: macos-latest
steps:
- name: Checkout Source Code
Expand Down
3 changes: 2 additions & 1 deletion README.mdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Swift bindings for [llama.cpp](https://github.com/ggerganov/llama.cpp) thanks to
## TODO

- [ ] Unit tests
- [ ] Model downloads from URL and HuggingFace

## How to install

Expand All @@ -29,7 +30,7 @@ Here's a quick example on how to use it. For more, please refer to an example ap
```swift
// Initialize model
let model = try Model(modelPath: "<model path>")
let llama = try LLama(modelLoader: model)
let llama = try LLama(model: model)

// Results are delivered through an `AsyncStream`
let prompt = "what is the meaning of life?"
Expand Down
4 changes: 2 additions & 2 deletions Sources/llama-cpp-swift/LLama.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation
import Logging
@preconcurrency import llama
import llama

/// An actor that handles inference using the LLama language model.
public actor LLama {
Expand Down Expand Up @@ -323,7 +323,7 @@ extension String {
/// - Parameter validatingUTF8: The array of CChars to initialize the string from.
fileprivate init?(validatingUTF8 cchars: [CChar]) {
if #available(macOS 15.0, iOS 18.0, *) {
self.init(validating: Data(cchars.map { UInt8(bitPattern: $0) }), as: UTF8.self)
self.init(decoding: Data(cchars.map { UInt8(bitPattern: $0) }), as: UTF8.self)
} else {
self.init(cString: cchars)
}
Expand Down

0 comments on commit d8f54eb

Please sign in to comment.