-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tim Wang
committed
May 5, 2024
1 parent
2d56552
commit e2a8b69
Showing
4 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!!! | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters