Giter VIP home page Giter VIP logo

openmagicai's Introduction

Swift Platforms CHAT GPT-4 CHAT GPT-3.5 CHAT GPT-3 Swift Package Manager Async Await Combine

OpenMagicAI: A Non-official OpenAI iOS library

This is a non-official iOS library of OpenAI.

OpenMagicAI is a friendly Swift library for accesing to OpenAI API. OpenAI api official docs reference.

Chat GPT-4 model support ❤️ (Limited beta) Join the waitlist

Example usage

There's a sample app here using the methods of OpenMagicAI library.

Chat Create Image List Models

Installation

Swift Package Manager (SPM)

SPM is a tool for managing the distribution of Swift code.

dependencies: [ 
  .package(url: "https://github.com/asyncios/OpenMagicAI.git", .upToNextMajor(from: "1.3.0"))
 ]

Usage

Set your API Key, if you don't have one create it here

let openMagicAI = OpenMagicAI(apiKey: "APIKEY")

Chat

openMagicAI.chat.createChatCompletion(
    messages: [.init(role: .user, content: "Give me some movie options for tonight")]
) { result in
       debugPrint(result)
}

// GPT-4 model
openMagicAI.chat.createChatCompletion(
    model: .gpt4,
    messages: [.init(role: .user, content: "Give me some movie options for tonight")]
) { result in
       debugPrint(result)
}

Closure usage

openMagicAI.images.createImage(prompt: "dog in a park") { result in
   debugPrint(result)
}

Async Await usage

Task {
  let result = try await openMagicAI.images.createImage("dog in a park")
  debugPrint(result)
}

Combine usage

openMagicAI.images.createImage(prompt: "dog in a park").sink { _ in
} receiveValue: { value in
  debugPrint(value)
}.store(in: &cancellables)

Endpoints available

Licenses

All source code is licensed under the MIT License.

openmagicai's People

Contributors

asyncios avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.