diff --git a/.github/workflows/ci.cd.prod.yml b/.github/workflows/ci.cd.prod.yml index bf41af8..15fb2b0 100644 --- a/.github/workflows/ci.cd.prod.yml +++ b/.github/workflows/ci.cd.prod.yml @@ -39,6 +39,14 @@ jobs: - name: Copy Jar run: cp ./build/libs/*.jar ./deploy + # appspec.yml 파일 복사 + - name: Copy appspec.yml + run: cp appspec.yml ./deploy + + # script files 복사 + - name: Copy script + run: cp ./scripts/*.sh ./deploy + - name: Make zip file run: zip -r ./easylead.zip ./deploy shell: bash @@ -52,3 +60,16 @@ jobs: - name: Upload to S3 run: aws s3 cp --region ap-northeast-2 ./easylead.zip s3://$S3_BUCKET_NAME/ + + # Deploy + - name: Deploy + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + run: | + aws deploy create-deployment \ + --application-name codedeploy-easylead \ + --deployment-group-name easylead \ + --file-exists-behavior OVERWRITE \ + --s3-location bucket=easy-lead-bucket,bundleType=zip,key=easylead.zip \ + --region ap-northeast-2 diff --git a/src/main/java/com/easylead/easylead/domain/gpt/business/GptBusiness.java b/src/main/java/com/easylead/easylead/domain/gpt/business/GptBusiness.java index 9909e7f..7c0bf02 100644 --- a/src/main/java/com/easylead/easylead/domain/gpt/business/GptBusiness.java +++ b/src/main/java/com/easylead/easylead/domain/gpt/business/GptBusiness.java @@ -25,4 +25,9 @@ public ResponseDTO getEasyToRead(String text) throws JsonProcessingException { public Flux ask(String text) throws JsonProcessingException { return gptService.askStream(text); } + + public ResponseDTO getEasyToReadCustom(String text) throws JsonProcessingException { + HttpRequest request = gptService.requestGPTCustom(text); + return gptConverter.toResponseDTO(gptService.responseGPT(request)); + } } diff --git a/src/main/java/com/easylead/easylead/domain/gpt/controller/GptController.java b/src/main/java/com/easylead/easylead/domain/gpt/controller/GptController.java index 6418deb..c7bcaa6 100644 --- a/src/main/java/com/easylead/easylead/domain/gpt/controller/GptController.java +++ b/src/main/java/com/easylead/easylead/domain/gpt/controller/GptController.java @@ -40,5 +40,12 @@ public Flux ask(Locale locale, } } + @GetMapping("/custom") + public ResponseEntity easyLeadCustom(@RequestParam String text) + throws JsonProcessingException { + return ResponseEntity.ok(gptBusiness.getEasyToReadCustom(text)); + + } + } diff --git a/src/main/java/com/easylead/easylead/domain/gpt/service/GptService.java b/src/main/java/com/easylead/easylead/domain/gpt/service/GptService.java index 8b35731..c7a59a0 100644 --- a/src/main/java/com/easylead/easylead/domain/gpt/service/GptService.java +++ b/src/main/java/com/easylead/easylead/domain/gpt/service/GptService.java @@ -32,6 +32,9 @@ public class GptService { @Value("${gpt.api_key}") private String gptApiKey; + + @Value("${gpt.api_key_custom}") + private String gptApiCustomkey; private final ObjectMapper objectMapper = new ObjectMapper() .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE ); @@ -193,4 +196,29 @@ public Flux askStream(String text) throws JsonProcessingException { .bodyToFlux(String.class); return eventStream; } + + public HttpRequest requestGPTCustom(String text) throws JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + List messages = new ArrayList<>(); + // Assistant API 사용할지 Prompt를 변경할지 선택하기 + // 시스템 역할 설정 + messages.add(new Message(text, "user")); + + ChatGPTRequestDTO chatGptRequest = new ChatGPTRequestDTO("ft:gpt-3.5-turbo-0125:personal::9klL6p0E", messages, 0.3,false); + String input = null; + input = mapper.writeValueAsString(chatGptRequest); + System.out.println(input); + System.out.println("apikey : " + gptApiCustomkey); + + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create("https://api.openai.com/v1/chat/completions")) + .header("Content-Type", "application/json") + .header("Authorization", "Bearer " + gptApiCustomkey) + .POST(HttpRequest.BodyPublishers.ofString(input)) + .build(); + + return request; + + + } }