Skip to content

Commit

Permalink
Fix: WebUi ID & Params
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekoer committed Nov 25, 2022
1 parent 01b4bc1 commit fb4d042
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "com.hcyacg"
version = "0.7.4"
version = "0.7.5"

repositories {
maven("https://maven.aliyun.com/repository/public")
Expand Down
17 changes: 10 additions & 7 deletions src/main/kotlin/Generate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.hcyacg.config.EhTagTranslationConfig
import com.hcyacg.data.LocalCookieJar
import com.hcyacg.data.PostData
import com.hcyacg.data.TranslateResult
import io.ktor.client.engine.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import kotlinx.serialization.decodeFromString
Expand Down Expand Up @@ -79,6 +78,8 @@ public object Generate {
}
}
})
}else{
logger.warning("目前还未填写您设置的webui账号密码,如果您未设置,请忽略本条消息")
}
}

Expand Down Expand Up @@ -129,11 +130,11 @@ public object Generate {
Config.script,//None
Config.putVariablePartsAtStartOfPrompt,//false
false,
null,
false,
"",
Config.xtype,
Config.xtype,//seed
Config.xvalues,
Config.ytype,
Config.ytype,//nonthing
Config.yvalues,
Config.drawLegend,//true
Config.keepRandomSeeds,//false
Expand All @@ -142,8 +143,9 @@ public object Generate {
"",
""),fn_index=Config.textFnIndex,session_hash = randomString)


var request = Request.Builder().apply {
url("${Config.stableDiffusionWebui}/api/predict/")
url("${Config.stableDiffusionWebui}/run/predict/")
post(json.encodeToString(PostData.serializer(),data).toRequestBody())
addHeader("content-type","application/json")
if (cookie.isNotBlank()) addHeader("cookie",cookie)
Expand All @@ -152,6 +154,7 @@ public object Generate {
var response = client.newCall(request).execute()
val element = json.parseToJsonElement(response.body.string())


val name = element.jsonObject["data"]?.jsonArray?.get(0)?.jsonArray?.get(0)?.jsonObject?.get("name")?.jsonPrimitive?.content
request = Request.Builder().apply {
url("${Config.stableDiffusionWebui}/file=$name")
Expand Down Expand Up @@ -262,7 +265,7 @@ public object Generate {
arrayOf("left","right","up", "down"),
false,
false,
null,
false,
"",
"",
64,
Expand All @@ -278,7 +281,7 @@ public object Generate {
"",""),fn_index=Config.imageFnIndex,session_hash = randomString)

var request = Request.Builder().apply {
url("${Config.stableDiffusionWebui}/api/predict/")
url("${Config.stableDiffusionWebui}/run/predict/")
post(json.encodeToString(PostData.serializer(),data).toRequestBody())
addHeader("content-type","application/json")
if (cookie.isNotBlank()) addHeader("cookie",cookie)
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public object Config : AutoSavePluginConfig("config") {
public var stableDiffusionWebui :String by value("http://127.0.0.1:7860")

@ValueName("textFnIndex")
@ValueDescription("接口id")
public var textFnIndex:Int by value(13)
@ValueDescription("文字接口id")
public var textFnIndex:Int by value(51)

@ValueName("imageFnIndex")
@ValueDescription("接口id")
public var imageFnIndex:Int by value(33)
@ValueDescription("图片接口id")
public var imageFnIndex:Int by value(74)

@ValueName("mode")
@ValueDescription("模式,仅限image2image")
Expand Down

0 comments on commit fb4d042

Please sign in to comment.