• Stars
    star
    141
  • Rank 259,971 (Top 6 %)
  • Language
    Objective-C
  • License
    Apache License 2.0
  • Created almost 2 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Kotlin Multiplatform library that provides access to ChatGPT and Open AI APIs

Maven Central Apache-2.0 Build Status Y-Chat

Y—Chat

Y—Chat is a Kotlin Multiplatform (KMP) project that provides a simple API for integrating the powerful ChatGPT language model developed by OpenAI into mobile applications running on multi platforms. The goal of this project is to abstract all the API call logic from ChatGPT, allowing developers to easily leverage the capabilities of the language model in their mobile applications.

The repository contains the source code for the Y—Chat library, along with examples and documentation for getting started with the library. The Y—Chat library provides a consistent interface for interacting with ChatGPT, regardless of the platform, and makes it easy to generate human-like text based on a given prompt or context.

The library uses Kotlin Multiplatform to generate artifacts for both iOS, macOS, Android and JVM, allowing developers to write code once and use it on multiple platforms. The project is open source and actively maintained, with contributions from the community encouraged. Overall, Y—Chat provides a convenient and powerful way for mobile developers to incorporate the advanced natural language processing capabilities of ChatGPT into their applications.

⚡️ Getting Started

iOS setup

  • Go to your project’s file settings and click "Add Package":

Y-ChatGPT iOS first screenshot

Y-ChatGPT iOS second screenshot

Once you have found the package click the "Add Package" button to add it to your project. Now you can start using the SDK in your iOS project!

See the code snippet below on how to initialize and use it one of the supported feature:

var yChat: YChat {
    YChatCompanion.shared.create(apiKey: "your-api-key") 
}

do {
  let result = try await chatGpt.completion()
                    .setInput(input: "Say this is a test.")
                    .setMaxTokens(tokens: 1024)
                    .saveHistory(isSaveHistory: false)
                    .set... // you can set more parameters
                    .execute()
} catch {
  // catch any error that may occurs on api call.  
}

Android/JVM setup

Add the following line to import the library via Gradle. First, make sure Maven Central has been added:

repositories {
    mavenCentral()
    // ...
}

Then, simply import the dependency to your build.gradle dependencies:

implementation("co.yml:ychat:1.4.1")

Take a look at the Kotlin code snippet below for an example of how to initialize and use one of the supported features:

val yChat by lazy {
  YChat.create("your-api-key")
}

try {
  val result = yChat.completion()
     .setInput("Say this is a test.")
     .saveHistory(false)
     .setMaxTokens(1024)
     .set... // you can set more parameters
     .execute()
  
} catch (e: exception) {
  // catch any error that may occurs on api call.  
}

Features

ℹ️ Sample apps

Take a look at our sample apps to learn how to use the SDK on different platforms:

Android Sample
iOS Sample
JVM Sample

🤝 Contributions

Feel free to make a suggestion or if you find any error in this project, please open an issue. Make sure to read our contribution guidelines before.

📄 License

    Copyright 2023 YML

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

More Repositories

1

YCharts

YCharts is a graph library for Android.
Kotlin
583
star
2

YMatterType

An opinionated take on Design System Typography for iOS and tvOS.
Swift
22
star
3

ytemplate-android

Y—Template aims to build your initial setup for your Android project quickly.
Kotlin
22
star
4

ycalendarpicker-ios

An easy-to-use and highly customizable month calendar.
Swift
12
star
5

YCoreUI

Core components for iOS and tvOS to accelerate building user interfaces in code.
Swift
9
star
6

YTooltip

Y-Tooltip is a light and extensible tooltip library for Jetpack Compose system
Kotlin
7
star
7

kmm-ycharts

Cross platform repository
Kotlin
5
star
8

ytags-ios

Accessible and customizable tag user interface elements for iOS.
Swift
5
star
9

ynetwork-android

Y-Network is a networking library for Android.
Kotlin
5
star
10

ybottomsheet-ios

An easy-to-use bottom sheet controller for iOS.
Swift
5
star
11

YComponentBrowser

Easily extend any project to include an intelligent design component browser.
Swift
4
star
12

ystepper-ios

Accessible and customizable shopping cart-style stepper for iOS.
Swift
4
star
13

yanalytics-ios

Y—Analytics: a generic analytics wrapper you can put around most any analytics framework
Swift
4
star
14

ycarousel-ios

An easy-to-use carousel that comes in both view and view controller flavors.
Swift
4
star
15

ysnackbar-ios

An easy-to-use UI component to display brief, transient messages to the user.
Swift
4
star
16

compose-testing-samples

This is a collection of all Android testing samples developed by YML engineering team.
Kotlin
4
star
17

lighthouse-slack-reports

Run lighthouse on a URL(s), send the report to a slack channel
TypeScript
3
star
18

yanalytics-firebase-ios

Y—Analytics implementation for Firebase SDK
Swift
3
star
19

ynetwork-ios

A networking layer for iOS and tvOS.
Swift
3
star
20

fe-component-library

fe-component-library
TypeScript
2
star
21

YTag-android

Y Tag is a UI element in Android (some times referred to as chips) which displays a piece of information. It consist of a leading icon(optional), Text and a trailing icon (optional).
Kotlin
2
star
22

ypersistence-ios

A Core Data wrapper that leverages the power of generics to allow you to work with custom model objects.
Swift
1
star
23

.github

All the templates. All of them.
1
star
24

ysidemenu-ios

Accessible and customizable side menu for iOS.
Swift
1
star
25

yanalytics-pendo-ios

Y—Analytics implementation for Pendo SDK
Swift
1
star
26

yanalytics-adobe-ios

Y—Analytics implementation for Adobe SDK
Swift
1
star