Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
dbd708e
Update README SU-DAL img and Deafult LLM Model Change to Gemini-1.5-f…
HOPARKSUNG Apr 28, 2025
69f83b0
Update user/HOPARKSUNG settings that contains yesterday (model, token…
HOPARKSUNG Apr 29, 2025
dfd5b83
Update my test file /test/운수좋은날시리즈
HOPARKSUNG Apr 29, 2025
cc6ef36
Add 출처 from 리버스운수좋은날
HOPARKSUNG Apr 29, 2025
f97dc72
Add translate 운수좋은날리버스 to LuckyDay, Test
HOPARKSUNG Apr 29, 2025
7b01986
Test: 2025-05-07_shaprk_laptop
HOPARKSUNG May 7, 2025
e0748e2
Test: 2025-05-07-#2
HOPARKSUNG May 7, 2025
1e3a14c
Test 0507 Sungho #3
HOPARKSUNG May 7, 2025
3ec45ce
Test 2025-05-07 17PM SUNGHO
HOPARKSUNG May 7, 2025
f9cf385
Remove My Test Txt Rainy Day
HOPARKSUNG May 7, 2025
e4afdbd
Test 2025-05-07 after rm sudal-logo
HOPARKSUNG May 7, 2025
f645ada
05-07 shpark changed :95 true & :119 주석해제
HOPARKSUNG May 7, 2025
ea47035
2025-05-07 20:53 make pizza text test by sh:
HOPARKSUNG May 7, 2025
68a7676
2025-05-07 21:17 I wanna go home... why me... noooo
HOPARKSUNG May 7, 2025
28dbb81
Join Qodo Discord and Copy Welcome Text
HOPARKSUNG May 7, 2025
a09b9b2
Test: pr_agetn/git_providers/utils.py custom change for Windows Temp …
HOPARKSUNG May 7, 2025
6af9dfb
Fix retry 3 to 2 :135 #attempts
HOPARKSUNG May 7, 2025
0695905
2025-05-11 return my config original to exam /sungho
HOPARKSUNG May 11, 2025
6bbb080
return to classic
HOPARKSUNG May 12, 2025
4fca69e
Merge remote-tracking branch 'upstream/main' into user/HOPARKSUNG
HOPARKSUNG May 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pr_agent/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pr_agent.config_loader import get_settings
from pr_agent.log import get_logger, setup_logger

log_level = os.environ.get("LOG_LEVEL", "INFO")
log_level = os.environ.get("LOG_LEVEL", "DEBUG")
setup_logger(log_level)


Expand Down
122 changes: 110 additions & 12 deletions pr_agent/git_providers/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import copy
import os
import tempfile
import sys #windows인지 운영체제 확인하고 싶어서, windows 환경일 경우만 개선 코드 적용
import time #time.sleep 사용을 위해 모듈이 필요

from dynaconf import Dynaconf
from starlette_context import context
Expand All @@ -10,19 +12,75 @@
get_git_provider_with_context)
from pr_agent.log import get_logger

# line 16~66 origin code
# def apply_repo_settings(pr_url):
# os.environ["AUTO_CAST_FOR_DYNACONF"] = "false"
# git_provider = get_git_provider_with_context(pr_url)
# if get_settings().config.use_repo_settings_file:
# repo_settings_file = None
# try:
# try:
# repo_settings = context.get("repo_settings", None)
# except Exception:
# repo_settings = None
# pass
# if repo_settings is None: # None is different from "", which is a valid value
# repo_settings = git_provider.get_repo_settings()
# try:
# context["repo_settings"] = repo_settings
# except Exception:
# pass

# error_local = None
# if repo_settings:
# repo_settings_file = None
# category = 'local'
# try:
# fd, repo_settings_file = tempfile.mkstemp(suffix='.toml')
# os.write(fd, repo_settings)
# new_settings = Dynaconf(settings_files=[repo_settings_file])
# for section, contents in new_settings.as_dict().items():
# section_dict = copy.deepcopy(get_settings().as_dict().get(section, {}))
# for key, value in contents.items():
# section_dict[key] = value
# get_settings().unset(section)
# get_settings().set(section, section_dict, merge=False)
# get_logger().info(f"Applying repo settings:\n{new_settings.as_dict()}")
# except Exception as e:
# get_logger().warning(f"Failed to apply repo {category} settings, error: {str(e)}")
# error_local = {'error': str(e), 'settings': repo_settings, 'category': category}

# if error_local:
# handle_configurations_errors([error_local], git_provider)
# except Exception as e:
# get_logger().exception("Failed to apply repo settings", e)
# finally:
# if repo_settings_file:
# try:
# os.remove(repo_settings_file)
# except Exception as e:
# get_logger().error(f"Failed to remove temporary settings file {repo_settings_file}", e)

# # enable switching models with a short definition
# if get_settings().config.model.lower() == 'claude-3-5-sonnet':
# set_claude_model()

# --- 이 함수 전체를 복사하여 기존 apply_repo_settings 함수와 교체하세요 ---
def apply_repo_settings(pr_url):
os.environ["AUTO_CAST_FOR_DYNACONF"] = "false"
git_provider = get_git_provider_with_context(pr_url)
repo_settings_file = None # finally 절에서 사용하기 위해 try 블록 외부에서 초기화
fd = -1 # 파일 디스크립터 초기화

if get_settings().config.use_repo_settings_file:
repo_settings_file = None
try:
# --- 리포지토리 설정 가져오기 (기존 로직과 동일) ---
try:
repo_settings = context.get("repo_settings", None)
except Exception:
repo_settings = None
pass
if repo_settings is None: # None is different from "", which is a valid value
if repo_settings is None:
repo_settings = git_provider.get_repo_settings()
try:
context["repo_settings"] = repo_settings
Expand All @@ -31,11 +89,18 @@ def apply_repo_settings(pr_url):

error_local = None
if repo_settings:
repo_settings_file = None
category = 'local'
try:
# --- 임시 파일 생성, 쓰기, 그리고 닫기 ---
# 1. 임시 파일 생성하고 파일 디스크립터(fd)와 경로(repo_settings_file) 얻기
fd, repo_settings_file = tempfile.mkstemp(suffix='.toml')
# 2. 파일에 설정 내용 쓰기
os.write(fd, repo_settings)
# 3. ★ 개선점 1: 파일 디스크립터 명시적으로 닫기 (파일 잠금 해제 도움) ★
os.close(fd)
fd = -1 # 닫은 후 초기화

# --- 임시 파일에서 설정 로드 (기존 로직과 동일) ---
new_settings = Dynaconf(settings_files=[repo_settings_file])
for section, contents in new_settings.as_dict().items():
section_dict = copy.deepcopy(get_settings().as_dict().get(section, {}))
Expand All @@ -44,25 +109,58 @@ def apply_repo_settings(pr_url):
get_settings().unset(section)
get_settings().set(section, section_dict, merge=False)
get_logger().info(f"Applying repo settings:\n{new_settings.as_dict()}")

except Exception as e:
# --- 설정 적용 중 오류 처리 (기존 로직과 동일) ---
get_logger().warning(f"Failed to apply repo {category} settings, error: {str(e)}")
error_local = {'error': str(e), 'settings': repo_settings, 'category': category}
# 쓰기/Dynaconf 실패 시에도 fd 닫기 시도
if fd != -1:
try:
os.close(fd)
except OSError:
pass # 이미 닫혔거나 유효하지 않으면 무시

if error_local:
handle_configurations_errors([error_local], git_provider)

if error_local:
handle_configurations_errors([error_local], git_provider)
except Exception as e:
get_logger().exception("Failed to apply repo settings", e)
finally:
if repo_settings_file:
try:
os.remove(repo_settings_file)
except Exception as e:
get_logger().error(f"Failed to remove temporary settings file {repo_settings_file}", e)
# --- 임시 파일 정리 (finally 블록은 항상 실행됨) ---
if repo_settings_file: # 임시 파일이 생성된 경우에만 실행
# ★ 개선점 2: 운영체제 확인 ★
if sys.platform == 'win32': # 현재 운영체제가 Windows 인 경우
# ★ 개선점 3 & 4: Windows 에서만 재시도 로직 및 로그 레벨 변경 적용 ★
attempts = 2 # 최대 2번 시도
delay = 0.1 # 시도 간 0.1초 대기
for i in range(attempts):
try:
os.remove(repo_settings_file) # 파일 삭제 시도
get_logger().debug(f"Successfully removed temporary settings file {repo_settings_file}")
repo_settings_file = None # 성공 시 경로 변수 초기화 (더 이상 삭제 시도 안 함)
break # 성공했으니 반복 종료
except Exception as e:
if i < attempts - 1: # 마지막 시도가 아니라면
get_logger().warning(f"Attempt {i+1} failed to remove {repo_settings_file} on Windows, retrying in {delay}s...")
time.sleep(delay) # 잠시 대기
else: # 마지막 시도에도 실패하면 ERROR 대신 WARNING 로그 남기기
get_logger().warning(f"Failed to remove temporary settings file {repo_settings_file} on Windows after {attempts} attempts", exc_info=True)
# 실패해도 repo_settings_file 변수는 유지 (수동 삭제 위해)
else:
# Windows가 아닌 다른 OS (macOS, Linux 등)의 경우
# 기존 방식대로 한 번만 삭제 시도하고 실패 시 ERROR 로그 남기기
try:
os.remove(repo_settings_file)
get_logger().debug(f"Successfully removed temporary settings file {repo_settings_file}")
repo_settings_file = None
except Exception as e:
get_logger().error(f"Failed to remove temporary settings file {repo_settings_file} on {sys.platform}", exc_info=True)

# enable switching models with a short definition
# --- 나머지 함수 로직 (기존과 동일) ---
if get_settings().config.model.lower() == 'claude-3-5-sonnet':
set_claude_model()

#

def handle_configurations_errors(config_errors, git_provider):
try:
Expand Down
14 changes: 7 additions & 7 deletions pr_agent/settings/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

[config]
# models
model="o4-mini"
fallback_models=["gpt-4.1"]
model="gemini/gemini-2.0-flash"
fallback_models=["gemini/gemini-2.0-flash"]
#model_reasoning="o4-mini" # dedictated reasoning model for self-reflection
#model_weak="gpt-4o" # optional, a weaker model to use for some easier tasks
# CLI
Expand All @@ -26,19 +26,19 @@ disable_auto_feedback = false
ai_timeout=120 # 2minutes
skip_keys = []
custom_reasoning_model = false # when true, disables system messages and temperature controls for models that don't support chat-style inputs
response_language="en-US" # Language locales code for PR responses in ISO 3166 and ISO 639 format (e.g., "en-US", "it-IT", "zh-CN", ...)
response_language="ko-KR" # Language locales code for PR responses in ISO 3166 and ISO 639 format (e.g., "en-US", "it-IT", "zh-CN", ...)
# token limits
max_description_tokens = 500
max_commits_tokens = 500
max_model_tokens = 32000 # Limits the maximum number of tokens that can be used by any model, regardless of the model's default capabilities.
custom_model_max_tokens=-1 # for models not in the default list
max_model_tokens = 64000 # Limits the maximum number of tokens that can be used by any model, regardless of the model's default capabilities.
custom_model_max_tokens=100000 # for models not in the default list
model_token_count_estimate_factor=0.3 # factor to increase the token count estimate, in order to reduce likelihood of model failure due to too many tokens - applicable only when requesting an accurate estimate.
# patch extension logic
patch_extension_skip_types =[".md",".txt"]
allow_dynamic_context=true
max_extra_lines_before_dynamic_context = 10 # will try to include up to 10 extra lines before the hunk in the patch, until we reach an enclosing function or class
patch_extra_lines_before = 5 # Number of extra lines (+3 default ones) to include before each hunk in the patch
patch_extra_lines_after = 1 # Number of extra lines (+3 default ones) to include after each hunk in the patch
patch_extra_lines_after = 3 # Number of extra lines (+3 default ones) to include after each hunk in the patch
secret_provider=""
cli_mode=false
ai_disclaimer_title="" # Pro feature, title for a collapsible disclaimer to AI outputs
Expand Down Expand Up @@ -116,7 +116,7 @@ include_generated_by_header=true
enable_large_pr_handling=true
max_ai_calls=4
async_ai_calls=true
#custom_labels = ['Bug fix', 'Tests', 'Bug fix with tests', 'Enhancement', 'Documentation', 'Other']
custom_labels = ['Bug fix', 'Tests', 'Bug fix with tests', 'Enhancement', 'Documentation', 'Other'] #origin #<-

[pr_questions] # /ask #
enable_help_text=false
Expand Down
2 changes: 1 addition & 1 deletion pr_agent/settings/custom_labels.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[config]
enable_custom_labels=false
enable_custom_labels=true

## template for custom labels
#[custom_labels."Bug fix"]
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ pytest-cov==5.0.0
pydantic==2.8.2
html2text==2024.2.26
# Uncomment the following lines to enable the 'similar issue' tool
# pinecone-client
# pandas
# pinecone
# pinecone-datasets @ git+https://github.com/mrT23/pinecone-datasets.git@main
# lancedb==0.5.1
# uncomment this to support language LangChainOpenAIHandler
Expand Down