openai-java icon indicating copy to clipboard operation
openai-java copied to clipboard

Spring boot project request timeout

Open as6116391 opened this issue 1 year ago • 24 comments

Strangely, neither restTemplate nor okhttp3 can call the official api. Postman can make normal requests.

as6116391 avatar Mar 06 '23 03:03 as6116391

The demo provided by the author cannot be accessed. The dependent version is 0.11.0

as6116391 avatar Mar 06 '23 03:03 as6116391

same

leonardocsc avatar Mar 06 '23 05:03 leonardocsc

me too

NDS308229535 avatar Mar 06 '23 11:03 NDS308229535

Caused by: java.net.SocketTimeoutException: connect timed out

NDS308229535 avatar Mar 06 '23 11:03 NDS308229535

哇找到组织了,我也是,开始我还以为是ChatMessage对象太多了导致的

xiayana avatar Mar 07 '23 02:03 xiayana

有没有大佬有解决方案

ruweizhong avatar Mar 07 '23 03:03 ruweizhong

可以考虑直接用境外服务器试试?

as6116391 avatar Mar 07 '23 03:03 as6116391

可以考虑使用外部环境服务器测试吗?

我放香港服务器上 也是500,而且顺便问一句,在开发聊天工程的时候,我按照官文的样例传输某用户的历史问题到LIST中以后,gpt还是会回复上面所有的问题,这也导致返回时间越来越长,你们也存在这个问题嘛

xiayana avatar Mar 07 '23 03:03 xiayana

可以考虑使用外部环境服务器测试吗?

我放香港服务器上 也是500,而且顺便问一句,在开发聊天工程的时候,我按照官文的样例传输某用户的历史问题到LIST中以后,gpt还是会回复上面所有的问题,这也导致返回时间越来越长,你们也存在这个问题嘛

我们测试发现,官方提供的接口就算用达芬奇引擎,回答的质量是没有官方的demo好,可能阉割了很多。如果包含上下文回答都是回复的比较慢,我看其他公司的demo都是一问一答的形式。

as6116391 avatar Mar 07 '23 03:03 as6116391

可以考虑使用外部环境服务器测试吗?

我放香港服务器上 也是500,而且顺便问一句,在开发聊天工程的时候,我按照官文的样例传输某用户的历史问题到LIST中以后,gpt还是会回复上面所有的问题,这也导致返回时间越来越长,你们也存在这个问题嘛

我们测试发现,官方提供的接口就算用达芬奇引擎,回答的质量是没有官方的demo好,可能阉割了很多。如果包含上下文回答都是回复的比较慢,我看其他公司的demo都是一问一答的形式。

嗯,这个确实我也发现了,可以试着将温度调低回答可能更准确一些。至于联系上下文的问题,看了其他人的问题回复,应该和stop这个参数相关。

xiayana avatar Mar 07 '23 03:03 xiayana

一直连接超时,有大佬解决了踢我一脚

KuhnXIE avatar Mar 07 '23 03:03 KuhnXIE

Search the issues. Someone built a proxy override that fixes this.

cryptoapebot avatar Mar 07 '23 03:03 cryptoapebot

Search the issues. Someone built a proxy override that fixes this.

Build a proxy forwarding in the project?

as6116391 avatar Mar 07 '23 04:03 as6116391

开vpn, 主方法调用前补充开启代理就行 System.setProperty("java.net.useSystemProxies", "true"); System.setProperty("https.proxyHost", "127.0.0.1"); System.setProperty("https.proxyPort", vpn的代理端口);

luoweiwei0908 avatar Mar 08 '23 02:03 luoweiwei0908

谢谢,我试一下

KuhnXIE avatar Mar 08 '23 02:03 KuhnXIE

I added a section to the README on how to set up a proxy https://github.com/TheoKanning/openai-java#adding-a-proxy

Let me know if that helps!

TheoKanning avatar Mar 08 '23 04:03 TheoKanning

Can you add agents based on the original OpenAiService ?

NDS308229535 avatar Mar 08 '23 07:03 NDS308229535

I added a section to the README on how to set up a proxy https://github.com/TheoKanning/openai-java#adding-a-proxy

Let me know if that helps!

Hello, I found the following exceptions in the visit times after joining the agent:

Caused by: java.io.IOException: unexpected end of stream on unknown Caused by: java.io.EOFException: \n not found: limit=0 content=…

as6116391 avatar Mar 08 '23 07:03 as6116391

Can you add agents based on the original OpenAiService ?

Directly find the OpenAiService class provided by the author, find the buildApi method to add proxy proxy information

as6116391 avatar Mar 08 '23 08:03 as6116391

thanks,let's me try

NDS308229535 avatar Mar 08 '23 08:03 NDS308229535

开vpn, 主方法调用前补充开启代理就行 System.setProperty("java.net.useSystemProxies", "true"); System.setProperty("https.proxyHost", "127.0.0.1"); System.setProperty("https.proxyPort", vpn的代理端口);

我发现加了之后,请求时会报java.lang.RuntimeException: java.io.IOException: unexpected end of stream on unknown异常

as6116391 avatar Mar 08 '23 08:03 as6116391

postman is ok

NDS308229535 avatar Mar 08 '23 08:03 NDS308229535

you can

开vpn, 主方法调用前补充开启代理就行 System.setProperty("java.net.useSystemProxies", "true"); System.setProperty("https.proxyHost", "127.0.0.1"); System.setProperty("https.proxyPort", vpn的代理端口);

我发现加了之后,请求时会报java.lang.RuntimeException: java.io.IOException: unexpected end of stream on unknown异常

我的没有问题了,

System.setProperty("http.proxyHost", "127.0.0.1"); System.setProperty("http.proxyPort", "7890"); System.setProperty("https.proxyHost", "127.0.0.1"); System.setProperty("https.proxyPort", "7890"); OpenAiService service = new OpenAiService("sk-xxxxxxxxx");

    List<ChatMessage> chatMessages=new ArrayList<>();
    ChatMessage chatMessage =new ChatMessage();
    chatMessage.setRole("user");
    chatMessage.setContent("你好");
    chatMessages.add(chatMessage);

    System.out.println("\nCreating completion...");
    ChatCompletionRequest completionRequest = ChatCompletionRequest.builder()
            .model("gpt-3.5-turbo-0301").messages(chatMessages).build();
    service.createChatCompletion(completionRequest).getChoices().forEach(System.out::println);

NDS308229535 avatar Mar 08 '23 10:03 NDS308229535

model 分别是 ? gpt-3.5-turbo-0301除了这个,还有gpt-4?

5pick avatar Mar 24 '23 16:03 5pick