A simple Swift package which acts as an OpenAI client for the GPT-3 API.

Overview

SwiftyGPT3

A simple Swift package which acts as an OpenAI client for GPT-3 brought to you by the Airgift Crew. Supports GPT-3 Codex!

Requirements

  • iOS 10.0 or later
  • tvOS 10.0 or later
  • watchOS 3.0 or later
  • macOS 10.12 or later
  • Xcode 8.0 or later

Installation

Install this package with Swift Package Manager

https://github.com/heysaik/SwiftyGPT3.git

Usage

import SwiftyGPT3

let openai = SwiftyGPT3(apiKey: "YOUR-OPENAI-KEY")
openai.performCompletions(
    prompt: "User: Hi AI!\nAI: Hello! What can I help you with?\nUser: Can you please tell me what the weather is?",
    maxTokens: 60,
    stopSequences: ["User:"],
    engine: .davinci
) { result, _ in
    if let response = result {
        print(response)
    }
}

Customizable Parameters

Parameter Description
prompt GPT-3 completes its answers based on the prompt you give. Learn more about designing a great prompt here.
maxTokens The maximum number of tokens to generate. Requests can use up to 2048 tokens shared between prompt and completion. One token is roughly 4 characters for normal English text
temperature Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.
topP Controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered.
frequencePenalty How much to penalize new tokens based on their existing frequency in the text so far. Decreases the model's likelihood to repeat the same line verbatim.
presencePenalty How much to penalize new tokens based on whether they appear in the text so far. Increases the model's likelihood to talk about new topics.
bestOf Generates multiple completions server-side, and displays only the best. Streaming only works when set to 1. Since it acts as a multiplier on the number of completions, this parameters can eat into your token quota very quickly - use caution!
stopSequenes Up to four sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
engine The engine to use for the API request. These engines provide a spectrum of capability, where davinci is the most capable and ada is the fastest.

TODO

  • Completion Endpoint
  • Classification Endpoint
  • Semantic Search Endpoint
  • Question-Answering Endpoint

Acknowledgements

You might also like...
Accelerated tensor operations and dynamic neural networks based on reverse mode automatic differentiation for every device that can run Swift - from watchOS to Linux
Accelerated tensor operations and dynamic neural networks based on reverse mode automatic differentiation for every device that can run Swift - from watchOS to Linux

DL4S provides a high-level API for many accelerated operations common in neural networks and deep learning. It furthermore has automatic differentiati

The Swift machine learning library.
The Swift machine learning library.

Swift AI is a high-performance deep learning library written entirely in Swift. We currently offer support for all Apple platforms, with Linux support

Matft is Numpy-like library in Swift. Function name and usage is similar to Numpy.
Matft is Numpy-like library in Swift. Function name and usage is similar to Numpy.

Numpy-like library in swift. (Multi-dimensional Array, ndarray, matrix and vector library)

Artificial intelligence/machine learning data structures and Swift algorithms for future iOS development. bayes theorem, neural networks, and more AI.

Swift Brain The first neural network / machine learning library written in Swift. This is a project for AI algorithms in Swift for iOS and OS X develo

A toolbox of AI modules written in Swift:  Graphs/Trees, Support Vector Machines, Neural Networks, PCA, K-Means, Genetic Algorithms
A toolbox of AI modules written in Swift: Graphs/Trees, Support Vector Machines, Neural Networks, PCA, K-Means, Genetic Algorithms

AIToolbox A toolbox of AI modules written in Swift: Graphs/Trees, Linear Regression, Support Vector Machines, Neural Networks, PCA, KMeans, Genetic Al

A framework for building fast genetic algorithms in Swift.
A framework for building fast genetic algorithms in Swift.

Revolver is a framework for building fast genetic algorithms in Swift 3.0. Features Chromosomes: strings, trees Genetic operators: reproduction, mutat

A Swift deep learning library with Accelerate and Metal support.
A Swift deep learning library with Accelerate and Metal support.

Serrano Aiming to offering popular and cutting edge techs in deep learning area on iOS devices, Serrano is developed as a tool for developers & resear

Running Swift automatic differentiation on iOS
Running Swift automatic differentiation on iOS

Differentiation Demo This is an example of Swift's automatic differentiation running on iOS. It is a modified version of the game from ARHeadsetKit tu

Track List Detail App With Swift

TrackListDetailApp TrackListDetailApp is master-detail application that containsa a list of items obtained from a iTunes Search API and show a detaile

Comments
  • SwiftyGPT3

    SwiftyGPT3

    I am trying to add SwiftyGPT3 package to my xcode/swiftUI project. It fails with error “could not find a branch named ‘feature/async-handlers’ in https://github.com/Alamofire/Alamofire.git.

    I am trying to run the GPT3 simulator within an iPhone App just for testing. I am using xcode 13.4.1 and ios/app/swiftUI

    opened by mfs786 0
Releases(0.1.1)
  • 0.1.1(Aug 27, 2021)

    Projects using SwiftyGPT3 were failing when building for Any iOS Device in Xcode 13. The reason for this stems from using Alamofire as a dependency. As such, we switched to using the features/async-handlers branch of Alamofire for this release.

    Source code(tar.gz)
    Source code(zip)
Owner
Airgift
An upcoming AR social media app
Airgift
A lightweight library to calculate tensors in Swift, which has similar APIs to TensorFlow's

TensorSwift TensorSwift is a lightweight library to calculate tensors, which has similar APIs to TensorFlow's. TensorSwift is useful to simulate calcu

Qoncept, Inc. 323 Oct 20, 2022
This is an open-source project for the aesthetic evaluation of images based on the deep learning-caffe framework, which we completed in the Victory team of Besti.

This is an open-source project for the aesthetic evaluation of images based on the deep learning-caffe framework, which we completed in the Victory team of Besti.

The Victory Group of Besti 102 Dec 15, 2022
TensorFlow C API Class Wrapper in Server Side Swift.

Perfect TensorFlow 简体中文 This project is an experimental wrapper of TensorFlow C API which enables Machine Learning in Server Side Swift. This package

PerfectlySoft Inc. 169 Dec 11, 2022
DL4S provides a high-level API for many accelerated operations common in neural networks and deep learning.

DL4S provides a high-level API for many accelerated operations common in neural networks and deep learning. It furthermore has automatic differentiati

DL4S Team 2 Dec 5, 2021
Tiny YOLO for iOS implemented using CoreML but also using the new MPS graph API.

YOLO with Core ML and MPSNNGraph This is the source code for my blog post YOLO: Core ML versus MPSNNGraph. YOLO is an object detection network. It can

Matthijs Hollemans 900 Dec 31, 2022
BrainCore is a simple but fast neural network framework written in Swift.

BrainCore is a simple but fast neural network framework written in Swift. It uses Metal which makes it screamin' fast. If you want to see it

Alejandro Isaza 377 Jun 29, 2022
MLKit is a simple machine learning framework written in Swift.

MLKit (a.k.a Machine Learning Kit) ?? MLKit is a simple machine learning framework written in Swift. Currently MLKit features machine learning algorit

Guled 152 Nov 17, 2022
A simple deep learning library for estimating a set of tags and extracting semantic feature vectors from given illustrations.

Illustration2Vec illustration2vec (i2v) is a simple library for estimating a set of tags and extracting semantic feature vectors from given illustrati

Masaki Saito 661 Dec 12, 2022
Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Jitsi Meet is a set of Open Source projects which empower users to use and deploy video conferencing platforms with state-of-the-art video quality and features.

Jitsi 19.1k Jan 5, 2023
A Swift library for creating and exporting CoreML Models in Swift

SwiftCoreMLTools A Swift Library for creating CoreML models in Swift. Work in progress This library expose a (function builder based) DSL as well as a

Jacopo Mangiavacchi 140 Dec 5, 2022