Skip to content

Commit

Permalink
Feat: OpenAIConfig 추가 (moyeothon#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
kduoh99 committed Oct 31, 2024
1 parent 4b99735 commit 928343a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.hackathon.momento.global.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
public class OpenAIConfig {

@Value("${openai.api.key}")
private String openAIKey;

@Bean
public RestTemplate template() {
RestTemplate restTemplate = new RestTemplate();
restTemplate.getInterceptors().add((request, body, execution) -> {
request.getHeaders().add("Authorization", "Bearer " + openAIKey);
return execution.execute(request, body);
});
return restTemplate;
}
}
8 changes: 7 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,10 @@ oauth:
client-id: ${KAKAO_CLIENT_ID}
redirect-uri: ${KAKAO_REDIRECT_URI}
admin-key: ${KAKAO_ADMIN_KEY}
token-url: ${KAKAO_TOKEN_URL}
token-url: ${KAKAO_TOKEN_URL}

openai:
model: ${OPEN_AI_MODEL}
api:
key: ${OPEN_AI_API_KEY}
url: ${OPEN_AI_API_URL}

0 comments on commit 928343a

Please sign in to comment.