Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.iml
.gradle
/local.properties
.idea
.DS_Store
/build
*/build
/captures
.externalNativeBuild
.cxx
xcuserdata
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
# chatgpt-sdk
ChatGPT SDK
# YChatGPT (Working in Progress 🚧)

ChatGPT is a large language model developed by OpenAI that is trained to generate human-like text based on a given prompt or context.

YChatGPT aims to abstract all API call logic from ChatGPT for multiple platforms.

## License

```
Copyright 2023 YChatGPT

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.
```
46 changes: 46 additions & 0 deletions android-sample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
plugins {
id("com.android.application")
kotlin("android")
}

android {
namespace = "co.yml.ychatgpt.android"
compileSdk = Config.COMPILE_SDK_VERSION
defaultConfig {
applicationId = "co.yml.ychatgpt.android"
minSdk = Config.MIN_SDK_VERSION
targetSdk = Config.TARGET_SDK_VERSION
versionCode = 1
versionName = "1.0"
}

buildFeatures {
compose = true
}

composeOptions {
kotlinCompilerExtensionVersion = "1.3.2"
}

packagingOptions {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}

buildTypes {
getByName("release") {
isMinifyEnabled = false
}
}
}

dependencies {
implementation(project(":chat-gpt"))
implementation(Dependencies.UI.COMPOSE_UI)
implementation(Dependencies.UI.COMPOSE_TOOLING)
implementation(Dependencies.UI.COMPOSE_TOOLING_PREVIEW)
implementation(Dependencies.UI.COMPOSE_FOUNDATION)
implementation(Dependencies.UI.COMPOSE_MATERIAL)
implementation(Dependencies.UI.COMPOSE_ACTIVITY)
}
17 changes: 17 additions & 0 deletions android-sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="false"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name="co.yml.ychatgpt.android.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package co.yml.ychatgpt.android

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview

class MainActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MyApplicationTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background
) {
GreetingView("Hello world")
}
}
}
}
}

@Composable
fun GreetingView(text: String) {
Text(text = text)
}

@Preview
@Composable
fun DefaultPreview() {
MyApplicationTheme {
GreetingView("Hello, Android!")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package co.yml.ychatgpt.android

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Shapes
import androidx.compose.material.Typography
import androidx.compose.material.darkColors
import androidx.compose.material.lightColors
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

@Composable
fun MyApplicationTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable () -> Unit
) {
val colors = if (darkTheme) {
darkColors(
primary = Color(0xFFBB86FC),
primaryVariant = Color(0xFF3700B3),
secondary = Color(0xFF03DAC5)
)
} else {
lightColors(
primary = Color(0xFF6200EE),
primaryVariant = Color(0xFF3700B3),
secondary = Color(0xFF03DAC5)
)
}
val typography = Typography(
body1 = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp
)
)
val shapes = Shapes(
small = RoundedCornerShape(4.dp),
medium = RoundedCornerShape(4.dp),
large = RoundedCornerShape(0.dp)
)

MaterialTheme(
colors = colors,
typography = typography,
shapes = shapes,
content = content
)
}
3 changes: 3 additions & 0 deletions android-sample/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<style name="AppTheme" parent="android:Theme.Material.NoActionBar"/>
</resources>
11 changes: 11 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
plugins {
//trick: for the same plugin versions in all sub-modules
id("com.android.application").version(Versions.GRADLE_PLUGIN).apply(false)
id("com.android.library").version(Versions.GRADLE_PLUGIN).apply(false)
kotlin("android").version(Versions.KOTLIN).apply(false)
kotlin("multiplatform").version(Versions.KOTLIN).apply(false)
}

tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
7 changes: 7 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
}
5 changes: 5 additions & 0 deletions buildSrc/src/main/kotlin/Config.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
object Config {
const val COMPILE_SDK_VERSION = 33
const val MIN_SDK_VERSION = 23
const val TARGET_SDK_VERSION = 33
}
37 changes: 37 additions & 0 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
object Versions {
const val GRADLE_PLUGIN = "7.3.0"
const val DOKKA_PLUGIN = "1.7.20"
const val KOTLIN = "1.7.20"
const val COMPOSE = "1.3.3"
const val COMPOSE_FOUNDATION = "1.3.1"
const val COMPOSE_ACTIVITY = "1.6.1"
const val KTOR = "2.2.2"
const val KOIN = "3.2.0"
const val MATERIAL_DESIGN = "1.6.1"
}

object Dependencies {

object Network {
const val KTOR_NEGOTIATION = "io.ktor:ktor-client-content-negotiation:${Versions.KTOR}"
const val KTOR_SERIALIZATION = "io.ktor:ktor-serialization-kotlinx-json:${Versions.KTOR}"
const val KTOR_CORE = "io.ktor:ktor-client-core:${Versions.KTOR}"
const val KTOR_LOGGING = "io.ktor:ktor-client-logging:${Versions.KTOR}"
const val KTOR_ANDROID = "io.ktor:ktor-client-android:${Versions.KTOR}"
const val KTOR_IOS = "io.ktor:ktor-client-ios:${Versions.KTOR}"
}

object DI {
const val KOIN_CORE = "io.insert-koin:koin-core:${Versions.KOIN}"
}

object UI {
const val MATERIAL_DESIGN = "com.google.android.material:${Versions.MATERIAL_DESIGN}"
const val COMPOSE_UI = "androidx.activity:activity-compose:${Versions.COMPOSE}"
const val COMPOSE_TOOLING = "androidx.compose.ui:ui-tooling:${Versions.COMPOSE}"
const val COMPOSE_TOOLING_PREVIEW = "androidx.compose.ui:ui-tooling-preview:${Versions.COMPOSE}"
const val COMPOSE_FOUNDATION = "androidx.compose.foundation:foundation:${Versions.COMPOSE_FOUNDATION}"
const val COMPOSE_MATERIAL = "androidx.compose.material:material:${Versions.COMPOSE_FOUNDATION}"
const val COMPOSE_ACTIVITY = "androidx.activity:activity-compose:${Versions.COMPOSE_ACTIVITY}"
}
}
Loading