Skip to content

Commit

Permalink
Merge pull request #93 from openharmony-dev/master
Browse files Browse the repository at this point in the history
core: add Spark V3.5 support.
  • Loading branch information
phodal committed Feb 29, 2024
2 parents 40cf325 + 80c525f commit c139860
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Expand Up @@ -33,6 +33,7 @@ class XingHuoProvider(val project: Project) : LLMProvider {
get() = when (this) {
XingHuoApiVersion.V1 -> ""
XingHuoApiVersion.V2 -> "v2"
XingHuoApiVersion.V3_5 -> "v3.5"
else -> "v3"
}

Expand Down Expand Up @@ -128,7 +129,7 @@ class XingHuoProvider(val project: Project) : LLMProvider {
val header = """
|host: spark-api.xf-yun.com
|date: $date
|GET /v${apiVersion.value}.1/chat HTTP/1.1
|GET /v${apiVersion.value}/chat HTTP/1.1
""".trimMargin()
val signature = hmacsha256.doFinal(header.toByteArray()).encodeBase64()
val authorization =
Expand All @@ -139,7 +140,7 @@ class XingHuoProvider(val project: Project) : LLMProvider {
"date" to date,
"host" to "spark-api.xf-yun.com"
)
val urlBuilder = "https://spark-api.xf-yun.com/v${apiVersion.value}.1/chat".toHttpUrl().newBuilder()
val urlBuilder = "https://spark-api.xf-yun.com/v${apiVersion.value}/chat".toHttpUrl().newBuilder()
params.forEach {
urlBuilder.addQueryParameter(it.key, it.value)
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/cc/unitmesh/devti/settings/Constants.kt
Expand Up @@ -9,14 +9,15 @@ enum class AIEngines {

val GIT_TYPE = arrayOf("Github" , "Gitlab")
val DEFAULT_GIT_TYPE = GIT_TYPE[0]
enum class XingHuoApiVersion(val value: Int) {
V1(1), V2(2), V3(3);
enum class XingHuoApiVersion(val value: Double) {
V1(1.1), V2(2.1), V3(3.1), V3_5(3.5);

companion object {
fun of(str: String): XingHuoApiVersion = when (str) {
"V1" -> V1
"V2" -> V2
"V3" -> V3
"V3_5" -> V3_5
else -> V3
}
}
Expand Down

0 comments on commit c139860

Please sign in to comment.