Skip to content

Commit

Permalink
build: 1.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
cssxsh committed Oct 17, 2022
1 parent 4be6404 commit eced5b2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = "xyz.cssxsh.mirai.novelai"
version = "1.0.9"
version = "1.0.10"

repositories {
mavenLocal()
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/xyz/cssxsh/mirai/novelai/NovelAiHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public object NovelAiHelper : KotlinPlugin(
JvmPluginDescription(
id = "xyz.cssxsh.mirai.plugin.novelai-helper",
name = "novelai-helper",
version = "1.0.9",
version = "1.0.10",
) {
author("cssxsh")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import net.mamoe.mirai.message.data.Image.Key.queryUrl
import net.mamoe.mirai.message.data.MessageSource.Key.quote
import net.mamoe.mirai.utils.ExternalResource.Companion.toExternalResource
import xyz.cssxsh.mirai.novelai.*
import xyz.cssxsh.mirai.novelai.data.*
import xyz.cssxsh.novelai.*
import kotlin.random.*

Expand Down Expand Up @@ -44,6 +45,7 @@ public object NovelAiCommand : SimpleCommand(
}
}
fromEvent.message.findIsInstance<Image>()?.let { source ->
if (NovelAiHelperConfig.image2image.not()) return
try {
val url = source.queryUrl()
val response = NovelAiHelper.client.http.get(url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ public object NovelAiFuCommand : SimpleCommand(
setBody(body)
contentType(ContentType.Application.Json)
}
var count = 3
val packet = with(statement) {
var cause: Exception? = null
while (kotlin.coroutines.coroutineContext.isActive) {
while (count-- > 0) {
return@with try {
body<ByteReadPacket>()
} catch (exception: SocketTimeoutException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ public object NovelAiHelperConfig : ReadOnlyPluginConfig("config"), NovelAiClien
override val proxy: String by value("")
override val doh: String by value("https://public.dns.iij.jp/dns-query")
override val ipv6: Boolean by value(true)
override val timeout: Long by value(30_000L)
override val timeout: Long by value(60_000L)
override val image: ImageModel by value(ImageModel.SAFE_DIFFUSION)

@ValueName("naifu_api")
public val local: String by value("http://127.0.0.1:6969/")

@ValueName("image2image")
public val image2image: Boolean by value(true)

override var token: String = ""
get() {
return field.ifEmpty {
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/xyz/cssxsh/novelai/ai/AIController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import kotlinx.coroutines.*
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import xyz.cssxsh.novelai.*
import kotlin.coroutines.*

public class AIController(private val client: NovelAiClient) {
public suspend fun generate(input: String, model: String, block: JsonObjectBuilder.() -> Unit): AiGenerate {
Expand Down Expand Up @@ -71,9 +70,10 @@ public class AIController(private val client: NovelAiClient) {
setBody(body)
contentType(ContentType.Application.Json)
}
var count = 3
val packet = with(statement) {
var cause: Exception? = null
while (coroutineContext.isActive) {
while (count-- > 0) {
return@with try {
body<ByteReadPacket>()
} catch (exception: SocketTimeoutException) {
Expand Down

0 comments on commit eced5b2

Please sign in to comment.