赞
踩
下载好JDK 17,在上图的JDK中不一定能看到。此时,选add JDK:选
zulu-17.jdk -> Contents -> Home
。
spring.ai.openai.api-key=sk-xxx
spring.ai.openai.chat.options.model=gpt-3.5-turbo
spring.ai.openai.chat.options.temperature=0.7
@RestController public class ChatController { private final OpenAiChatClient chatClient; @Autowired public ChatController(OpenAiChatClient chatClient) { this.chatClient = chatClient; } @GetMapping("/ai/generate") public Map generate(@RequestParam(value = "message", defaultValue = "美国的首都是?") String message) { return Map.of("generation", chatClient.call(message)); } @GetMapping("/ai/generateStream") public Flux<ChatResponse> generateStream(@RequestParam(value = "message", defaultValue = "美国的首都是?") String message) { Prompt prompt = new Prompt(new UserMessage(message)); return chatClient.stream(prompt); } }
接触过各种llm的api就知道,那叫一个千奇百怪。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。