-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prompt fixes #3722
base: main
Are you sure you want to change the base?
Prompt fixes #3722
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Sweep: PR ReviewAuthor: wwzeng1
|
GITHUB_APP_ID = "327588" | |
GITHUB_BOT_USERNAME = os.environ.get("GITHUB_BOT_USERNAME") | |
if GITHUB_BOT_USERNAME and not GITHUB_BOT_USERNAME.endswith("[bot]"): | |
GITHUB_BOT_USERNAME = GITHUB_BOT_USERNAME + "[bot]" |
View Diff
sweepai/logn/trace_util.py
: Sweep has identified a redundant function: The new main() function is redundant with the existing main() function in trace_util.py. It performs the same operations without adding any new functionality.sweep/sweepai/logn/trace_util.py
Lines 38 to 41 in 921ec16
@trace_function | |
def main(): | |
result = foo(3, 4) | |
print(f"Result: {result}") |
View Diff
sweepai/logn/trace_util.py
: Sweep has identified a redundant function: The new foo(x, y) is an exact duplicate of the existing foo(x, y) function in code_snippet 0, providing no new functionality or improvements. It is redundant and can be removed.sweep/sweepai/logn/trace_util.py
Lines 43 to 45 in 921ec16
def foo(x, y): | |
time.sleep(0.1) # Simulating some work | |
return bar(x) + bar(y) |
View Diff
sweepai/logn/trace_util.py
: Sweep has identified a redundant function: The new bar(x) function is redundant because an identical bar(x) function already exists in the trace_util.py code snippet that multiplies the input by 2 after a delay.sweep/sweepai/logn/trace_util.py
Lines 47 to 49 in 921ec16
def bar(x): | |
time.sleep(0.2) # Simulating some work | |
return x * 2 |
View Diff
Potential Issues
Sweep is unsure if these are issues, but they might be worth checking out.
sweepai/utils/github_utils.py
- The change in
sweepai/utils/github_utils.py
assumes thatGITHUB_BOT_USERNAME
will always be set correctly if defined, which might lead to incorrect username assignments.
sweep/sweepai/utils/github_utils.py
Lines 706 to 718 in 921ec16
try: | |
if not GITHUB_BOT_USERNAME: | |
g = Github(os.environ.get("GITHUB_PAT")) | |
CURRENT_USERNAME = g.get_user().login | |
else: | |
CURRENT_USERNAME = GITHUB_BOT_USERNAME | |
except Exception: | |
try: | |
slug = get_app()["slug"] | |
CURRENT_USERNAME = f"{slug}[bot]" | |
except Exception: |
View Diff
sweepai/logn/trace_util.py
- The
sys.settrace
function is set globally within thetrace_function
decorator, which could interfere with other parts of the program or other threads that also usesys.settrace
.
sweep/sweepai/logn/trace_util.py
Lines 5 to 32 in 921ec16
def trace_function(func): | |
def wrapper(*args, **kwargs): | |
def trace_calls(frame, event, arg): | |
if event != 'call': | |
return None | |
stack = inspect.stack() | |
indent = ' ' * (len(stack) - 2) | |
stack_info = ' -> '.join(frame.function for frame in stack[1:]) | |
start_time = time.time() | |
def trace_returns(frame, event, arg): | |
if event == 'return': | |
duration = time.time() - start_time | |
logger.info(f"{indent}Exiting function: {frame.f_code.co_name} (Stack: {stack_info}) (Duration: {duration:.4f} seconds)") | |
return None | |
logger.info(f"{indent}Entering function: {frame.f_code.co_name} (Stack: {stack_info})") | |
return trace_returns | |
sys.settrace(trace_calls) | |
result = func(*args, **kwargs) | |
sys.settrace(None) | |
View Diff
Summary
This pull request refactored environment variable handling, improved prompt messages, and enhanced function tracing and logging.
In sweepai/config/server.py
, the default assignment logic for GITHUB_BOT_USERNAME
based on the environment was removed. Now, GITHUB_BOT_USERNAME
is only modified to append "[bot]" if it is already set.
In sweepai/core/prompts.py
, prompt messages were refined for clarity. The redundant phrase "proposed plan a plan" was corrected, and instructions for identifying and fixing errors were made clearer and more structured.
In sweepai/logn/trace_util.py
, the line-by-line tracing mechanism was replaced with a function call tracing mechanism. A new trace_function
decorator was introduced to log function entry, exit, and execution duration using the loguru
logger.
In sweepai/utils/github_utils.py
, the code was updated to check for GITHUB_BOT_USERNAME
before making an API call to get the current GitHub username. If GITHUB_BOT_USERNAME
is set, it is used directly, reducing unnecessary API calls.
No description provided.