Skip to content

Commit

Permalink
fixed gha stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinlu1248 committed Aug 16, 2023
1 parent be0ac1f commit a2765c6
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 33 deletions.
8 changes: 4 additions & 4 deletions sweepai/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,16 +441,16 @@ async def webhook(raw_request: Request):
logger.info(f"Handling check suite for {request.repository.full_name}")
_, g = get_github_client(request.installation.id)
repo = g.get_repo(request.repository.full_name)
if request.check_run.pull_requests and issue.labels:
issue = repo.get_issue(request.check_run.pull_requests[0].number)
if not any(label.name == "sweep" for label in issue.labels):
return {"success": True}
pull_request = repo.get_pull(request.check_run.pull_requests[0].number)
if (
len(request.check_run.pull_requests) > 0
and pull_request.user.login.lower().startswith("sweep")
and request.check_run.conclusion == "failure"
and not pull_request.title.startswith("[DRAFT]")
and pull_request.labels
and any(
label.name.lower() == "sweep" for label in pull_request.labels
)
):
logger.info("Handling check suite")
pr_change_request = PRChangeRequest(
Expand Down
1 change: 1 addition & 0 deletions sweepai/config/server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

PREFIX = "prod"

print(f"Using prefix: {PREFIX}")
ENV = PREFIX

Expand Down
60 changes: 32 additions & 28 deletions sweepai/core/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,19 +334,22 @@ def fetch():
"output": output,
}
)
try:
posthog.capture(
self.chat_logger.data["username"],
"call_openai",
{
"model": model,
"max_tokens": max_tokens - token_sub,
"input_tokens": messages_length,
"output_tokens": count_tokens.call(output["content"]),
},
)
except Exception as e:
logger.warning(e)
if self.chat_logger:
try:
token_count = count_tokens.call(output)
posthog.capture(
self.chat_logger.data.get("username"),
"call_openai",
{
"model": model,
"max_tokens": max_tokens - token_sub,
"input_tokens": messages_length,
"output_tokens": token_count,
"chat_logger_data": self.chat_logger.data,
},
)
except Exception as e:
logger.warning(e)
return output
except Exception as e:
logger.warning(e)
Expand Down Expand Up @@ -393,21 +396,22 @@ def fetch():
"output": output,
}
)
try:
token_count = count_tokens.call(output)
posthog.capture(
self.chat_logger.data["username"],
"call_openai",
{
"model": model,
"max_tokens": max_tokens - token_sub,
"input_tokens": messages_length,
"output_tokens": token_count,
},
)
except Exception as e:
logger.warning(e)
raise e
if self.chat_logger:
try:
token_count = count_tokens.call(output)
posthog.capture(
self.chat_logger.data.get("username"),
"call_openai",
{
"model": model,
"max_tokens": max_tokens - token_sub,
"input_tokens": messages_length,
"output_tokens": token_count,
"chat_logger_data": self.chat_logger.data,
},
)
except Exception as e:
logger.warning(e)
return output
except Exception as e:
logger.warning(e)
Expand Down
2 changes: 1 addition & 1 deletion sweepai/handlers/on_check_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{error_logs}
This is likely a linting or type-checking issue with the source code. Update the code and avoid modifying the existing tests."""
This is likely a linting or type-checking issue with the source code. Update the code changed by the PR. Don't modify the existing tests."""


def get_dirs(zipfile: zipfile.ZipFile):
Expand Down

0 comments on commit a2765c6

Please sign in to comment.