Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/vyfor/groq-kt
Browse files Browse the repository at this point in the history
  • Loading branch information
vyfor committed Nov 10, 2024
2 parents b3f2cb2 + f6987f9 commit 1bff29e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ bin/
.DS_Store

kls_database.db

src/jvmTest/
7 changes: 4 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@file:OptIn(org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl::class)
@file:Suppress("OPT_IN_USAGE")
@file:OptIn(ExperimentalWasmDsl::class)

import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinMultiplatform
import com.vanniktech.maven.publish.SonatypeHost
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl

plugins {
kotlin("multiplatform") version "2.0.10"
Expand Down Expand Up @@ -65,10 +65,11 @@ kotlin {
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")
}
}
val commonTest by getting {
val jvmTest by getting {
dependencies {
implementation(kotlin("test"))
implementation("io.ktor:ktor-client-cio:$ktorVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import io.github.vyfor.groqkt.GroqModel
import io.github.vyfor.groqkt.api.chat.CompletionFunctionCallType.Auto
import io.github.vyfor.groqkt.api.chat.CompletionFunctionCallType.None
import io.github.vyfor.groqkt.api.chat.CompletionResponseFormatType.JSON_OBJECT
import io.github.vyfor.groqkt.api.chat.CompletionToolChoice.*
import io.github.vyfor.groqkt.api.chat.UserMessageContent.Image
import io.github.vyfor.groqkt.api.chat.UserMessageContent.Image.ImageObject
import io.github.vyfor.groqkt.api.chat.UserMessageContent.Text
Expand Down Expand Up @@ -173,11 +172,11 @@ data class ChatCompletionRequest(
var user: String? = null

fun noFunctionCalls() {
functionCall = CompletionFunctionCallType.None
functionCall = None
}

fun autoFunctionCalls() {
functionCall = CompletionFunctionCallType.Auto
functionCall = Auto
}

fun functionCall(name: String) {
Expand Down Expand Up @@ -246,15 +245,15 @@ class ChatCompletionMessageBuilder {
CompletionMessage.User(
UserMessageType.Array(
imageContent =
UserMessageContent.Image(UserMessageContent.Image.ImageObject(url = image)))))
Image(ImageObject(url = image)))))
}

fun user(content: String?, image: String?, name: String? = null) {
messages.add(
CompletionMessage.User(
UserMessageType.Array(
UserMessageContent.Text(content),
UserMessageContent.Image(UserMessageContent.Image.ImageObject(url = image))),
Text(content),
Image(ImageObject(url = image))),
name))
}

Expand Down Expand Up @@ -472,8 +471,8 @@ sealed class CompletionMessage(val role: String) {
element<String>("toolCallId")
element<String>("functionName")
element<String>("toolName")
element<UserMessageContent.Text>("textContent")
element<UserMessageContent.Image>("imageContent")
element<Text>("textContent")
element<Image>("imageContent")
element<CompletionFunctionCall>("functionCall")
element<List<CompletionToolCall>>("toolCalls")
}
Expand Down Expand Up @@ -548,13 +547,13 @@ sealed class CompletionMessage(val role: String) {
User(
UserMessageType.Array(
imageContent =
UserMessageContent.Image(UserMessageContent.Image.ImageObject(url = image))))
Image(ImageObject(url = image))))

fun user(content: String?, image: String?, name: String? = null) =
User(
UserMessageType.Array(
UserMessageContent.Text(content),
UserMessageContent.Image(UserMessageContent.Image.ImageObject(url = image))),
Text(content),
Image(ImageObject(url = image))),
name)

fun assistant(
Expand Down Expand Up @@ -590,8 +589,8 @@ sealed class UserMessageType {
*/
@Serializable
data class Array(
val textContent: UserMessageContent.Text = UserMessageContent.Text(),
val imageContent: UserMessageContent.Image = UserMessageContent.Image()
val textContent: UserMessageContent.Text = Text(),
val imageContent: Image = Image()
) : UserMessageType() {
init {
require(textContent.type != null || imageContent.type != null) {
Expand Down

0 comments on commit 1bff29e

Please sign in to comment.