chatgpt spring boot starter
v1.0.5
이 스타터는 OpenAI 공식 API를 기반으로합니다. SpringBoot 프로젝트에서 Chatgpt를 쉽게 사용할 수 있습니다.
채팅
많은 모델을 사용하여 Chatgpt와 채팅 할 수 있습니다. 또한 멀티 메시지가 지원되므로 일련의 메시지 (대화 기록 포함)를 입력으로 가져 와서 응답 메시지를받을 수 있습니다.
이미지 생성
프롬프트를 제공하고 이미지를 생성하십시오.
<dependency>
<groupId>io.github.flashvayne</groupId>
<artifactId>chatgpt-spring-boot-starter</artifactId>
<version>1.0.5</version>
</dependency>
chatgpt :
api-key : xxxxxxxxxxx # api-key. It can be generated here https://platform.openai.com/account/api-keys
# some more properties(model,max-tokens...etc.) have default values. Also you can config them here. @ Autowired
private ChatgptService chatgptService ;
public void test (){
String responseMessage = chatgptService . multiChat ( Arrays . asList ( new MultiChatMessage ( "user" , "how are you?" )));
System . out . print ( responseMessage ); //nnAs an AI language model, I don't have feelings, but I'm functioning well. Thank you for asking. How can I assist you today?
}
public void test2 (){
String responseMessage = chatgptService . sendMessage ( "how are you" );
System . out . print ( responseMessage ); //I'm doing well, thank you. How about you?
} @ Autowired
private ChatgptService chatgptService ;
public void testMultiChat (){
List < MultiChatMessage > messages = Arrays . asList (
new MultiChatMessage ( "system" , "You are a helpful assistant." ),
new MultiChatMessage ( "user" , "Who won the world series in 2020?" ),
new MultiChatMessage ( "assistant" , "The Los Angeles Dodgers won the World Series in 2020." ),
new MultiChatMessage ( "user" , "Where was it played?" ));
String responseMessage = chatgptService . multiChat ( messages );
System . out . print ( responseMessage ); //The 2020 World Series was played at Globe Life Field in Arlington, Texas.
} @ Autowired
private ChatgptService chatgptService ;
public void testImage (){
String imageUrl = chatgptService . imageGenerate ( "A cute baby sea otter" );
System . out . print ( imageUrl ); //https://oaidalleapip.......
}
public void testImageList (){
List < String > images = chatgptService . imageGenerate ( "A cute baby sea otter" , 2 , ImageSize . SMALL , ImageFormat . URL );
System . out . print ( images . toString ()); //["https://oaidalleapipr.....ZwA%3D","https://oaidalleapipr....RE0%3D"]
}Demo-Chatgpt-Spring-Boot-Starter
이메일 : [email protected]
블로그 : https://vayne.cc
이 프로젝트를 지원해 주신 JetBrains에게 감사드립니다. 그들은 우리에게 JetBrains 개발 도구 라이센스를 제공했습니다.