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

doc: update pr preview bot #581

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions codegen-examples/examples/pr_review_bot/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import codegen
from codegen import Codebase
from codegen.sdk.codebase.config import CodebaseConfig
from codegen.sdk.secrets import Secrets
from codegen.shared.configs.models.feature_flags import CodebaseFeatureFlags

github_token = "Your github token"
Expand All @@ -16,10 +15,10 @@
def run(codebase: Codebase):
context_symbols = set()

modified_symbols = codebase.get_modified_symbols_in_pr(pr_number)
modified_symbols, patch = codebase.get_modified_symbols_in_pr(pr_number)
for symbol in modified_symbols:
# Get direct dependencies
deps = symbol.dependencies(max_depth=2)

Check failure on line 21 in codegen-examples/examples/pr_review_bot/run.py

View workflow job for this annotation

GitHub Actions / mypy

error: Missing positional argument "self" in call to "__call__" of "ProxyProperty" [call-arg]
context_symbols.update(deps)

# Prepare context for LLM
Expand All @@ -29,19 +28,20 @@
"name": symbol.name,
"type": symbol.symbol_type.value,
"filepath": symbol.filepath,
"content": symbol.content,

Check failure on line 31 in codegen-examples/examples/pr_review_bot/run.py

View workflow job for this annotation

GitHub Actions / mypy

error: "Symbol[Any, Any]" has no attribute "content" [attr-defined]
}
for symbol in modified_symbols
],
"context_symbols": [
{
"name": symbol.name,
"type": symbol.symbol_type.value,

Check failure on line 38 in codegen-examples/examples/pr_review_bot/run.py

View workflow job for this annotation

GitHub Actions / mypy

error: Item "Import[Any]" of "Symbol[Any, Any] | Import[Any]" has no attribute "symbol_type" [union-attr]
"filepath": symbol.filepath,
"content": symbol.content,

Check failure on line 40 in codegen-examples/examples/pr_review_bot/run.py

View workflow job for this annotation

GitHub Actions / mypy

error: Item "Symbol[Any, Any]" of "Symbol[Any, Any] | Import[Any]" has no attribute "content" [union-attr]

Check failure on line 40 in codegen-examples/examples/pr_review_bot/run.py

View workflow job for this annotation

GitHub Actions / mypy

error: Item "Import[Any]" of "Symbol[Any, Any] | Import[Any]" has no attribute "content" [union-attr]
}
for symbol in context_symbols
],
"pr_patch": patch,
}

system_prompt = """
Expand All @@ -67,18 +67,18 @@
5. Suggestions for testing
"""

review = codebase.ai_client.llm_query_with_retry(messages=[{"role": "system", "content": system_prompt}, {"role": "user", "content": prompt}], model="gpt-4", max_tokens=2000, temperature=0.7)

Check failure on line 70 in codegen-examples/examples/pr_review_bot/run.py

View workflow job for this annotation

GitHub Actions / mypy

error: "OpenAI" has no attribute "llm_query_with_retry" [attr-defined]
return review


if __name__ == "__main__":
print("Starting codebase analysis...")
codebase = Codebase.from_repo(

Check failure on line 76 in codegen-examples/examples/pr_review_bot/run.py

View workflow job for this annotation

GitHub Actions / mypy

error: Unexpected keyword argument "shallow" for "from_repo" of "Codebase" [call-arg]
"getsentry/sentry",
shallow=False,
language="python",
config=CodebaseConfig(
secrets=Secrets(openai_key=open_ai_key, github_api_key=github_token),

Check failure on line 81 in codegen-examples/examples/pr_review_bot/run.py

View workflow job for this annotation

GitHub Actions / mypy

error: Name "Secrets" is not defined [name-defined]
feature_flags=CodebaseFeatureFlags(
sync_enabled=True,
),
Expand Down
Loading