Skip to content

Commit

Permalink
Merge pull request #38 from sanikani/main
Browse files Browse the repository at this point in the history
[Feat] : LLM Server와 API 통신 구현
  • Loading branch information
sanikani authored Aug 24, 2024
2 parents 5519072 + 0ffe90b commit 299533c
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
@NoArgsConstructor
public class LLMMessageRequest {

private String chatMessage;
private String topic;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@
@NoArgsConstructor
public class LLMMessageResponse {

private int status;

private String message;

private LLMServerResponseBody body;
String response;
}


Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public SendChatMessageResponse sendMessage(SendChatMessageRequest request) {
LLMMessageResponse LLMMessageResponse = llmService.sendMessage(request.getChatMessage());

//LLM 메시지 저장
ChatMessage llmMessage = ChatMessage.createServerMessage(LLMMessageResponse.getBody().getChatMessage(), chatRoom);
ChatMessage llmMessage = ChatMessage.createServerMessage(LLMMessageResponse.getResponse(), chatRoom);
chatMessageRepository.save(llmMessage);

return new SendChatMessageResponse(userMessage.getMessage(), llmMessage.getMessage(), userMessage.getTimestamp(), llmMessage.getTimestamp());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

import com.HP028.chatbot.chat.dto.LLMMessageResponse;
import com.HP028.chatbot.chat.dto.LLMServerResponseBody;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

@Service
@Primary
public class LLMServiceDummy implements LLMService{
@Override
public LLMMessageResponse sendMessage(String chatMessage) {
return new LLMMessageResponse(200, "채팅 응답 성공", new LLMServerResponseBody("채팅 메시지"));
return new LLMMessageResponse("채팅 메시지");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
import com.HP028.chatbot.chat.dto.LLMMessageRequest;
import com.HP028.chatbot.chat.dto.LLMMessageResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;

@Service
@RequiredArgsConstructor
@Primary
public class LLMServiceImpl implements LLMService{

private final WebClient webClient;

public LLMMessageResponse sendMessage(String chatMessage) {
return webClient.post()
.uri("/chat")
.uri("/prompt/playground/")
.bodyValue(new LLMMessageRequest(chatMessage))
.retrieve()
.bodyToMono(LLMMessageResponse.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class WebClientConfig {

@Bean
public WebClient webClient(WebClient.Builder webClientBuilder) {
String llmServerUrl = "http://localhost:8000";
String llmServerUrl = "https://prime-sloth-properly.ngrok-free.app";
return webClientBuilder.baseUrl(llmServerUrl).build();
}
}
6 changes: 3 additions & 3 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
logging.level.root=debug
logging.level.org.springframework.web=debug
logging.level.org.hibernate=debug
logging.level.root=info
logging.level.org.springframework.web=info
logging.level.org.hibernate=info

0 comments on commit 299533c

Please sign in to comment.