Closed nextyale-10 closed 9 months ago
public class Test { public static void main(String[] args) { OpenAiStreamClient client = OpenAiStreamClient.builder() .apiKey(Arrays.asList("sk-********","sk-********")) //自定义key的获取策略:默认KeyRandomStrategy //.keyStrategy(new KeyRandomStrategy()) .keyStrategy(new FirstKeyStrategy()) //自己做了代理就传代理地址,没有可不不传 // .apiHost("https://自己代理的服务器地址/") .build(); //聊天模型:gpt-3.5 ConsoleEventSourceListener eventSourceListener = new ConsoleEventSourceListener(); Message message = Message.builder().role(Message.Role.USER).content("你好啊我的伙伴!").build(); ChatCompletion chatCompletion = ChatCompletion.builder().messages(Arrays.asList(message)).build(); client.streamChatCompletion(chatCompletion, eventSourceListener); CountDownLatch countDownLatch = new CountDownLatch(1); try { countDownLatch.await(); } catch (InterruptedException e) { e.printStackTrace(); } } }
此代码片段的 countdownlatch 没有被释放过,或许能在你的框架里加上 latch 而不是用户自己加? 个人浅见
这个是main测试,仅供参考 @nextyale-10
此代码片段的 countdownlatch 没有被释放过,或许能在你的框架里加上 latch 而不是用户自己加? 个人浅见