不调用 ChateGPT 的接口,直接返回数据。

This commit is contained in:
YuCheng Hu 2023-02-07 14:52:05 -05:00
parent b3cfaa3c73
commit 8c6840832a
1 changed files with 8 additions and 4 deletions

View File

@ -23,6 +23,7 @@ import org.springframework.stereotype.Service;
import java.io.IOException;
import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
@ -156,19 +157,22 @@ public class WeChatService {
OpenAiService service = new OpenAiService("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");
CompletionRequest completionRequest = new CompletionRequestBuilder()
.setPrompt(content)
.setModel("text-davinci-003")
.setMaxTokens(700)
.setPrompt(content)
.setMaxTokens(500)
.setEcho(true)
.setUser("testing")
.setLogitBias(new HashMap<>())
.createCompletionRequest();
// service.createCompletion(completionRequest).getChoices().size();
// content = service.createCompletion(completionRequest).getChoices().get(0).getText();
content = service.createCompletion(completionRequest).getChoices().get(0).getText();
weChatMessage.setToUserName(toUserName);
weChatMessage.setFromUserName(fromUserName);
weChatMessage.setContent("我们已收到您的消息。");
weChatMessage.setContent(content);
weChatMessage.setCreateTime(Instant.now().toEpochMilli());
return WeChatUtils.covertToWeChatMessageXmlStr(weChatMessage);