sigmadelta
12/23/2024, 2:10 PMCaused by: JsError: Error from javascript[TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body.
My implementation looks like this:
suspend fun sendCohereChatMessage(msg: String) {
val chatRequest = ChatRequest(
stream = true,
model = "command-r-plus-08-2024",
messages = listOf(RequestMessage(role = "user", content = msg))
)
client.serverSentEvents(
urlString = "<https://api.cohere.com/v2/chat>",
request = {
setBody(chatRequest)
contentType(ContentType.Application.Json)
}
) {
incoming.collect { event ->
println(event)
}
}
}
Does anyone know how to get passed this issue or is it simply not supported?Daniel Pitts
12/23/2024, 3:29 PMDaniel Pitts
12/23/2024, 3:31 PMrequest
block, make sure you set the method correctly. It should probably be POSTsigmadelta
12/23/2024, 3:34 PMmethod = <http://HttpMethod.Post|HttpMethod.Post>
to the request block fixed the issue indeed.
Thanks a bunch!Daniel Pitts
12/23/2024, 4:13 PM