Skip to content

Commit 85097f8

Browse files
committed
refactor: apu url 환경변수 처리
1 parent 9ec0ef6 commit 85097f8

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import os
2+
3+
KOREAEXIM_API_URL = os.getenv("KOREAEXIM_API_URL", "")
4+
KOREAEXIM_API_KEY = os.getenv("KOREAEXIM_API_KEY", "")

core/tariff_prediction/tools/get_exchange_rate_info.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
import pandas as pd
44
import re
55
from langchain_core.tools import tool
6-
from core.shared.utils.llm import get_llm
76
import os
87

8+
from core.tariff_prediction.constants.api_config import KOREAEXIM_API_URL, KOREAEXIM_API_KEY
9+
910
# 환율 지원 국가 목록
1011
SUPPORTED_COUNTRIES = {
1112
'미국': 'USD', '일본': 'JPY', '유럽연합': 'EUR', '중국': 'CNY',
@@ -27,19 +28,18 @@ def get_currency_for_country(country: str) -> str:
2728
return SUPPORTED_COUNTRIES.get(country, 'USD')
2829

2930
def get_exchange_rate_api(cur_unit: str, situation: str = '해외직구'):
30-
"""실제 한국수출입은행 API를 사용하여 환율을 조회합니다."""
31-
url = 'https://oapi.koreaexim.go.kr/site/program/financial/exchangeJSON'
31+
"""한국수출입은행 API를 사용하여 환율을 조회합니다."""
32+
3233
today_date = datetime.now().strftime('%Y%m%d')
33-
api_key = os.getenv('KOREAEXIM_API_KEY', '') # 환경변수에서 API 키 가져오기
3434

3535
params = {
36-
'authkey': api_key,
36+
'authkey': KOREAEXIM_API_KEY,
3737
'searchdate': today_date,
3838
'data': 'AP01'
3939
}
4040

4141
try:
42-
response = requests.get(url, params=params)
42+
response = requests.get(KOREAEXIM_API_URL, params=params)
4343
response.raise_for_status()
4444
data = pd.DataFrame(response.json())
4545

0 commit comments

Comments
 (0)