Skip to content

Commit

Permalink
feat: GPT User Advice
Browse files Browse the repository at this point in the history
  • Loading branch information
DDonghyeo committed Jan 11, 2024
1 parent d1bb31d commit f383248
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.kim3ho1.yourprotein.controller;

import com.kim3ho1.yourprotein.gpt.dto.request.GPTCompletionChatRequest;
import com.kim3ho1.yourprotein.gpt.dto.response.CompletionChatResponse;
import com.kim3ho1.yourprotein.gpt.service.GPTChatRestService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -16,13 +19,20 @@
@RequestMapping("/gpt")
public class GptController {
private final GptService gptService;

private final GPTChatRestService gptChatRestService;

@GetMapping("/total")
public ResponseEntity<String> totalAdvice() {
return ResponseEntity.ok(gptService.totalAdvice());
public ResponseEntity<CompletionChatResponse> totalAdvice() {
return ResponseEntity.ok(
gptChatRestService.completionChat(new GPTCompletionChatRequest("gpt-3.5-turbo", "user", gptService.totalAdvice(), 5000))
);
}

@GetMapping("/plan")
public ResponseEntity<String> planAdvice() {
return ResponseEntity.ok(gptService.planAdvice());
public ResponseEntity<CompletionChatResponse> planAdvice() {
return ResponseEntity.ok(
gptChatRestService.completionChat(new GPTCompletionChatRequest("gpt-3.5-turbo", "user", gptService.planAdvice(), 5000))
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.kim3ho1.yourprotein.gpt.dto.response.CompletionChatResponse;
import com.kim3ho1.yourprotein.gpt.dto.response.CompletionResponse;
import com.kim3ho1.yourprotein.gpt.service.GPTChatRestService;
import com.theokanning.openai.completion.chat.ChatMessage;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand All @@ -23,7 +24,7 @@ public class ChatGPTRestController {

@PostMapping("/completion/chat")
public CompletionChatResponse chat(final @RequestBody HashMap<String, String> prompt) {
return completionChat(new GPTCompletionChatRequest("gpt-3.5-turbo", "user", prompt.get("prompt"), 1000));
return completionChat(new GPTCompletionChatRequest("gpt-3.5-turbo", "user", prompt.get("prompt"), 5000));
}


Expand Down

0 comments on commit f383248

Please sign in to comment.