Skip to content

Commit

Permalink
Merge pull request #15 from easy-lead/feat/#13
Browse files Browse the repository at this point in the history
Feat/#13
  • Loading branch information
oU-Ua authored Jul 14, 2024
2 parents b2089fa + 6b07d94 commit 548d04c
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.cd.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ public ResponseDTO getEasyToRead(String text) throws JsonProcessingException {
public Flux<String> 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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,12 @@ public Flux<String> ask(Locale locale,
}
}

@GetMapping("/custom")
public ResponseEntity<ResponseDTO> easyLeadCustom(@RequestParam String text)
throws JsonProcessingException {
return ResponseEntity.ok(gptBusiness.getEasyToReadCustom(text));

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -193,4 +196,29 @@ public Flux<String> askStream(String text) throws JsonProcessingException {
.bodyToFlux(String.class);
return eventStream;
}

public HttpRequest requestGPTCustom(String text) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
List<Message> 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;


}
}

0 comments on commit 548d04c

Please sign in to comment.