Grt1228 / chatgpt-java

ChatGPT Java SDK支持流式输出、Gpt插件、联网。支持OpenAI官方所有接口。ChatGPT的Java客户端。OpenAI GPT-3.5-Turb GPT-4 Api Client for Java
https://chatgpt-java.unfbx.com
Apache License 2.0
3.34k stars 816 forks source link

在使用ChatGPT 3.5 类模型时遇到的报错 #48

Closed PengLx closed 1 year ago

PengLx commented 1 year ago

`try {

        val client = buildClient()
        val eventSourceListener = ChatEventSourceListener(chat, Model.CHATGPT_3_5_TURBO)
        val message = Message.builder().role(Message.Role.USER).content(text).build()
        val chatCompletion = ChatCompletion.builder().messages(listOf(message)).build()
        client!!.streamChatCompletion(chatCompletion, eventSourceListener)
        val countDownLatch = CountDownLatch(1)

        try {
            countDownLatch.await()
        } catch (e: InterruptedException) {
            e.printStackTrace()
        }
    } catch (e: Exception) {
        chat.msgs.add(Msg(chat.friend, mutableStateOf(e.stackTraceToString()), dateFormat))
    }`

错误显示

OpenAI SSE链接异常 data: { "error": { "message": "Invalid URL (POST /v1/chat/completions)", "type": "invalid_request_error", "param": null, "code": null } } 异常 null

PengLx commented 1 year ago

测试使用达芬奇模型无此问题

Grt1228 commented 1 year ago

应该是你的参数入参有问题。建议断点看下。 这个报错是官方返回的

PengLx commented 1 year ago

`

val client = buildClient() val eventSourceListener = ChatEventSourceListener(chat, Model.CHATGPT_3_5_TURBO) val message = Message.builder().role(Message.Role.USER).content("你好啊我的伙伴!").build() val chatCompletion = ChatCompletion.builder().messages(listOf(message)).build() client!!.streamChatCompletion(chatCompletion, eventSourceListener) val countDownLatch = CountDownLatch(1)

        try {
            countDownLatch.await()
        } catch (e: InterruptedException) {
            e.printStackTrace()
        }`

即使使用样例也是发出同样的返回 OpenAiStreamClientTest.java

Grt1228 commented 1 year ago

@PengLx 可以进群去具体看下你的问题