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

Sweep: create a new agent to be used in ticket_utils.py (✓ Sandbox Passed) #3159

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions sweepai/agents/query_filter_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from sweepai.core.prompts import doc_query_rewriter_prompt
from sweepai.utils.openai_proxy import OpenAIProxy
from sweepai.watch import logger


class QueryFilterAgent:
def __init__(self):
self.openai_proxy = OpenAIProxy()

def filter_query(self, search_query: str) -> str:
try:
prompt = doc_query_rewriter_prompt.format(issue=search_query)
filtered_query = self.openai_proxy.call_openai(
model="gpt-3.5-turbo",
messages=[{"role": "system", "content": prompt}],
max_tokens=60,
temperature=0.0
)
return filtered_query
except Exception as e:
logger.error(f"Error filtering query: {e}")
raise e
2 changes: 2 additions & 0 deletions sweepai/utils/ticket_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from sweepai.utils.event_logger import posthog
from sweepai.utils.github_utils import ClonedRepo
from sweepai.utils.progress import TicketProgress
from sweepai.agents.query_filter_agent import QueryFilterAgent

@file_cache()
def get_top_k_snippets(
Expand Down Expand Up @@ -109,6 +110,7 @@ def fetch_relevant_files(
logger.info("Fetching relevant files...")
try:
search_query = (title + summary + replies_text).strip("\n")
search_query = QueryFilterAgent().filter_query(search_query)
replies_text = f"\n{replies_text}" if replies_text else ""
formatted_query = (f"{title.strip()}\n{summary.strip()}" + replies_text).strip(
"\n"
Expand Down
Loading