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

能否支持上下文关联?

Open pycle opened this issue 2 years ago • 9 comments

似乎没法进行一段连续的对话,能否支持上下文关联? Uploading 112312312.png…

pycle avatar Feb 21 '23 05:02 pycle

112312312

pycle avatar Feb 21 '23 05:02 pycle

How did you implement this?

cryptoapebot avatar Feb 21 '23 13:02 cryptoapebot

使用这个库开放了个接口,用react做前端,实现聊天?

pycle avatar Feb 22 '23 01:02 pycle

In the example above, what call did you make to the API and using what parameters?

cryptoapebot avatar Feb 22 '23 03:02 cryptoapebot

.model("text-davinci-003") .topP(1.0) .n(1) .temperature(0.0) .maxTokens(800)

pycle avatar Feb 23 '23 01:02 pycle

看官方示例库,连续对话是需要把历史聊天记录都插入prompt,并且使用stop分割,如下: List<String> STOP = Arrays.asList("\nMi:", "\nAI:"); json.put("prompt","MI:在吗\nAI:在的\nMI介绍下自己\AI:");

zengwp avatar Feb 24 '23 03:02 zengwp

prompt中输入之前会话的所有内容即可实现该功能

mrjiangyan avatar Feb 27 '23 05:02 mrjiangyan

计算费用是根据输出token计算的还是输入token计算的啊

Xsir0 avatar Mar 04 '23 02:03 Xsir0

采用的是输出token。可以考虑用新的chatgpt-api以及模型参数了,价格更低

mrjiangyan avatar Mar 06 '23 01:03 mrjiangyan

加起来都算上,惊不惊喜意不意外

GodJiong avatar May 18 '23 07:05 GodJiong

用session 来保持连续对话

sm9i avatar May 26 '23 03:05 sm9i

用session 来保持连续对话

咋用?求指點,感謝大佬

8337009 avatar May 29 '23 10:05 8337009

用session 来保持连续对话

咋用?求指點,感謝大佬

我还没试过这是百度给的。我的api好像用不了

sm9i avatar May 31 '23 02:05 sm9i

用session 来保持连续对话

咋用?求指點,感謝大佬

我还没试过这是百度给的。我的api好像用不了

有百度的連接嗎?我看官方API文檔沒有提到與session相關的 輸入

8337009 avatar May 31 '23 04:05 8337009

用session 来保持连续对话

咋用?求指點,感謝大佬

我还没试过这是百度给的。我的api好像用不了

有百度的連接嗎?我看官方API文檔沒有提到與session相關的 輸入

刚才找了下没找到..不过网上还是有session id这个玩意 但是调用的方法跟现在的不一样了。我不知道能不能用 你可以问问 gpt 他会有带session的方法

sm9i avatar May 31 '23 05:05 sm9i

image 这是gpt给我的,我之前也确实查到过,但到目前我的sdk还没解决好,用不了,没试过这个你可以试试

sm9i avatar May 31 '23 05:05 sm9i

image 这是gpt给我的,我之前也确实查到过,但到目前我的sdk还没解决好,用不了,没试过这个你可以试试

嗯嗯 可以試試 但是奇怪的是 官方API文檔并沒有提及 這個屬性 https://platform.openai.com/docs/api-reference/ 图片

我試試吧 還是覺得奇怪

8337009 avatar May 31 '23 07:05 8337009

image 这是gpt给我的,我之前也确实查到过,但到目前我的sdk还没解决好,用不了,没试过这个你可以试试

嗯嗯 可以試試 但是奇怪的是 官方API文檔并沒有提及 這個屬性 https://platform.openai.com/docs/api-reference/ 图片

我試試吧 還是覺得奇怪 根本不行!!!!! 图片 图片

8337009 avatar May 31 '23 08:05 8337009

I didn't follow everything, but two notes.

  1. Chat uses the chat completions endpoint, not the completions one.
https://api.openai.com/v1/chat/completions
  1. The chat completions API from OpenAI currently does not support the session_id. There is an ID that is returned, but the above endpoint does not supporting using id or session_id as a parameter.
https://platform.openai.com/docs/guides/chat/introduction

cryptoapebot avatar May 31 '23 14:05 cryptoapebot