Skip to content

Commit

Permalink
Add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Wang committed May 5, 2024
1 parent 2d56552 commit e2a8b69
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Tim Wang

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# SwiftLlama

This is basically a wrapper of [llama.cpp](https://github.com/ggerganov/llama.cpp.git) package
and the purpose of this repo is to provide a swiftier api.

## Install

.package(url: "https://github.com/ShenghaiWang/SwiftLlama.git", from: "0.1.0")

## Usage

### 1 Initialise swiftLlama using model path.

let swiftLlama = try SwiftLlama(modelPath: path))

### 2 Call it

#### Using AsyncStream method

for try await value in await swiftLlama.start(for: prompt) {
result += value
}

#### Using Combine publisher

await swiftLlama.start(for: prompt)
.sink { _ in

} receiveValue: {[weak self] value in
self?.result += value
}.store(in: &cancallable)

## Test projects

Please refer to the TestProjects folder for usage.

[This video](https://youtu.be/w1VEM00cJWo) was the command line app running with Llama 3 model.

For using it in iOS or MacOS app, please refer to the [TestProjects folder](https://github.com/ShenghaiWang/SwiftLlama/tree/main/TestProjects)

## Welcome to contribute!!!



13 changes: 13 additions & 0 deletions TestProjects/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Test project for SwiftLlama package

There are three targets in this demostration:
one iOS app target, one MacOS app target and one command line app,
which are located in different folder group. Also, there is a Shared folder group
that contains code/resources that are shared.

Please note there's no models are included in this repo.
If you want to run these apps,
you need to download your own models and modify the code to use them accordingly.
In cased of the command line app, you just need to give the right path to the app
in scheme settings or in terminal app when you run it in terminal.

2 changes: 2 additions & 0 deletions TestProjects/TestApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
4B1334F72BE5C4AC0020AB8E /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
4B1334F82BE5C4AC0020AB8E /* TestApp_iOSApp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestApp_iOSApp.swift; sourceTree = "<group>"; };
4B1334F92BE5C4AC0020AB8E /* ContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
4B51A47B2BE7449700F65BFC /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
4BEE1DB32BE70024001CE949 /* swiftllama */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = swiftllama; sourceTree = BUILT_PRODUCTS_DIR; };
4BEE1DB52BE70024001CE949 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -85,6 +86,7 @@
4B0B05512BE5B44E002BC7AF = {
isa = PBXGroup;
children = (
4B51A47B2BE7449700F65BFC /* README.md */,
4BB1E3E42BE646BB00F1D21A /* Shared */,
4B1334F32BE5C4AC0020AB8E /* TestApp-iOS */,
4B0B05782BE5C451002BC7AF /* TestApp-Macos */,
Expand Down

0 comments on commit e2a8b69

Please sign in to comment.