Skip to content

Commit

Permalink
v1.0 iOS SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
ErisMik committed May 13, 2024
1 parent 3c0dd16 commit cd6add4
Show file tree
Hide file tree
Showing 106 changed files with 6,485 additions and 3 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/ios-demos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: iOS Demos

on:
workflow_dispatch:
push:
branches: [ main ]
paths:
- 'demo/ios/**'
- '.github/workflows/ios-demos.yml'
pull_request:
branches: [ main, 'v[0-9]+.[0-9]+' ]
paths:
- 'demo/ios/**'
- '.github/workflows/ios-demos.yml'

jobs:
build-completion-demo:
runs-on: macos-latest
defaults:
run:
working-directory: demo/ios/PicoLLMCompletionDemo

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Cocoapods
run: gem install cocoapods

- name: Run Cocoapods
run: pod install

- name: Build
run: xcrun xcodebuild build
-configuration Debug
-workspace PicoLLMCompletionDemo.xcworkspace
-sdk iphoneos
-scheme PicoLLMCompletionDemo
-derivedDataPath ddp
CODE_SIGNING_ALLOWED=NO

build-chat-demo:
runs-on: macos-latest
defaults:
run:
working-directory: demo/ios/PicoLLMChatDemo

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Cocoapods
run: gem install cocoapods

- name: Run Cocoapods
run: pod install

- name: Build
run: xcrun xcodebuild build
-configuration Debug
-workspace PicoLLMChatDemo.xcworkspace
-sdk iphoneos
-scheme PicoLLMChatDemo
-derivedDataPath ddp
CODE_SIGNING_ALLOWED=NO
55 changes: 55 additions & 0 deletions .github/workflows/ios-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: iOS Tests

on:
workflow_dispatch:
push:
branches: [ main ]
paths:
- '.github/workflows/ios-local.yml'
- 'binding/ios/PicoLLMAppTest/**'
- 'resources/.test/**'
pull_request:
branches: [ main, 'v[0-9]+.[0-9]+' ]
paths:
- '.github/workflows/ios-local.yml'
- 'binding/ios/PicoLLMAppTest/**'
- 'resources/.test/**'

defaults:
run:
working-directory: binding/ios/PicoLLMAppTest

jobs:
build:
name: Run iOS Tests
runs-on: pv-ios

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Run Cocoapods
run: pod install

- name: Inject AccessKey
run: sed -i '.bak' 's:{TESTING_ACCESS_KEY_HERE}:${{secrets.PV_VALID_ACCESS_KEY}}:'
PicoLLMAppTestUITests/BaseTest.swift

- name: Inject Resource URL
run: sed -i '.bak' 's?{TESTING_MODEL_URL_HERE}?http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.bin/latest/phi2-290.bin?'
PicoLLMAppTestUITests/BaseTest.swift

- name: XCode Build
run: xcrun xcodebuild build-for-testing
-configuration Debug
-workspace PicoLLMAppTest.xcworkspace
-sdk iphoneos
-scheme PicoLLMAppTest
-derivedDataPath ddp
CODE_SIGNING_ALLOWED=NO

- name: Run Tests on Simulator
run: xcrun xcodebuild test
-workspace PicoLLMAppTest.xcworkspace
-scheme PicoLLMAppTest
-destination 'platform=iOS Simulator,name=iPhone 13'
2 changes: 1 addition & 1 deletion .github/workflows/swift-codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
- '.github/workflows/swift-codestyle.yml'

jobs:
check-switch-codestyle:
check-swift-codestyle:
runs-on: ubuntu-latest

steps:
Expand Down
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,20 @@ For more information about Python demos go to [demo/python](demo/python/README.m

### iOS Demos

To run the completion demo, go to [demo/ios/PicoLLMCompletionDemo](demo/ios/PicoLLMCompletionDemo) and run:

```console
pod install
```

Replace `let ACCESS_KEY = "${YOUR_ACCESS_KEY_HERE}"` in the file [VieModel.swift](demo/ios/PicoLLMCompletionDemo/PicoLLMCompletionDemo/ViewModel.swift) with your AccessKey obtained from [Picovoice Console](https://console.picovoice.ai/).

Then, using [Xcode](https://developer.apple.com/xcode/), open the generated `PicoLLMCompletionDemo.xcworkspace` and run the application.

To learn about how to use picoLLM in a chat application, try out the [Chat demo](demo/ios/PicoLLMChatDemo).

For more information about iOS demos go to [demo/python](demo/ios/README.md).

### Web Demos

### C Demos
Expand Down Expand Up @@ -163,6 +177,22 @@ the resources using `pllm.release()`.

### iOS SDK

Create an instance of the engine and generate a prompt completion:

```c
import PicoLLM

let pllm = try PicoLLM(
accessKey: "${ACCESS_KEY}",
modelPath: "${MODEL_PATH}")

let res = pllm.generate(prompt: "${PROMPT}")
print(res.completion)
```
Replace `${ACCESS_KEY}` with yours obtained from Picovoice Console, `${MODEL_PATH}` to the path to a model file
downloaded from Picovoice Console, and `${PROMPT}` to a prompt string.
### Web SDK
### C SDK
Expand Down
19 changes: 19 additions & 0 deletions binding/ios/PicoLLM-iOS.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Pod::Spec.new do |s|
s.name = 'picoLLM-iOS'
s.module_name = 'PicoLLM'
s.version = '1.0.0'
s.license = {:type => 'Apache 2.0'}
s.summary = 'picoLLM Inference Engine'
s.description =
<<-DESC
picoLLM Inference Engine iOS SDK.
DESC
s.homepage = 'https://github.com/Picovoice/picollm/tree/master/binding/ios'
s.author = { 'Picovoice' => '[email protected]' }
s.source = { :git => '' }
s.ios.deployment_target = '13.0'
s.swift_version = '5.0'
s.vendored_frameworks = 'lib/ios/PvPicoLLM.xcframework'
s.source_files = '*.{swift}'
s.exclude_files = 'PicoLLMAppTest/**'
end
Loading

0 comments on commit cd6add4

Please sign in to comment.