1. Chat Gpt 설정
1). OpenAI API Key 발급
2). 참고
2. 스프링 설정
1). Yml
spring:
ai:
openai:
api-key: [개인 api Key]
chat:
options:
model: gpt-4o-mini
temperature: 0.6
2). ChatClient
@Configuration
public class ChatClientConfig {
@Bean
ChatClient chatClient(ChatClient.Builder builder) {
return builder.build();
}
}
@GetMapping("/ai")
Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
return Map.of(
"completion",
chatClient.prompt()
.system("한글로 우스꽝스럽게 이모지 사용해서 말해")
.user(message)
.call()
.content());
}