Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Prompt fixes #3722

wants to merge 3 commits into from

Conversation

wwzeng1
Copy link
Contributor

@wwzeng1 wwzeng1 commented May 12, 2024

No description provided.

Copy link

vercel bot commented May 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sweep-chat 🔄 Building (Inspect) Visit Preview 💬 Add feedback May 13, 2024 8:06pm
sweep-chat-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 13, 2024 8:06pm
sweep-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 13, 2024 8:06pm

Copy link
Contributor

sweep-nightly bot commented Jun 1, 2024

Sweep: PR Review

Author: wwzeng1

Sweep Found These Issues

  • In sweepai/config/server.py: The removal of the default values for GITHUB_BOT_USERNAME based on the environment could lead to issues if the environment variable is not set, as the code will no longer have a fallback mechanism.
  • 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

  • In 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.
  • @trace_function
    def main():
    result = foo(3, 4)
    print(f"Result: {result}")

    View Diff

  • In 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.
  • def foo(x, y):
    time.sleep(0.1) # Simulating some work
    return bar(x) + bar(y)

    View Diff

  • In 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.
  • 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 that GITHUB_BOT_USERNAME will always be set correctly if defined, which might lead to incorrect username assignments.
  • 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 the trace_function decorator, which could interfere with other parts of the program or other threads that also use sys.settrace.
  • 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.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant