Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: add Spark V3.5 support. #93

Merged
merged 1 commit into from
Feb 29, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
get() = when (this) {
XingHuoApiVersion.V1 -> ""
XingHuoApiVersion.V2 -> "v2"
XingHuoApiVersion.V3_5 -> "v3.5"

Check warning on line 36 in src/main/kotlin/cc/unitmesh/devti/llms/xianghuo/XingHuoProvider.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/cc/unitmesh/devti/llms/xianghuo/XingHuoProvider.kt#L36

Added line #L36 was not covered by tests
else -> "v3"
}

Expand Down Expand Up @@ -128,7 +129,7 @@
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

Check warning on line 132 in src/main/kotlin/cc/unitmesh/devti/llms/xianghuo/XingHuoProvider.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/cc/unitmesh/devti/llms/xianghuo/XingHuoProvider.kt#L132

Added line #L132 was not covered by tests
""".trimMargin()
val signature = hmacsha256.doFinal(header.toByteArray()).encodeBase64()
val authorization =
Expand All @@ -139,7 +140,7 @@
"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()

Check warning on line 143 in src/main/kotlin/cc/unitmesh/devti/llms/xianghuo/XingHuoProvider.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/cc/unitmesh/devti/llms/xianghuo/XingHuoProvider.kt#L143

Added line #L143 was not covered by tests
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@

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);

Check warning on line 13 in src/main/kotlin/cc/unitmesh/devti/settings/Constants.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/cc/unitmesh/devti/settings/Constants.kt#L12-L13

Added lines #L12 - L13 were not covered by tests

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

Check warning on line 20 in src/main/kotlin/cc/unitmesh/devti/settings/Constants.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/cc/unitmesh/devti/settings/Constants.kt#L20

Added line #L20 was not covered by tests
else -> V3
}
}
Expand Down
Loading