Skip to content

Commit

Permalink
feat: make model optional
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddigital committed Sep 29, 2024
1 parent f8ffca8 commit d4d8e9c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/code_review.yml/code_review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,9 @@ jobs:
pr_number: ${{ github.event.pull_request.number }}
repository: ${{ github.repository }}
env:
# This is provided by default, you do not need to change this
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Update the below in your GitHub repo actions secrets to use your OpenAI API key
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
# Update the below to use the model of your choice
OPENAI_MODEL: "gpt-4o"
3 changes: 2 additions & 1 deletion src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@

OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
GITHUB_TOKEN = os.getenv('GITHUB_TOKEN')
DEBUG_MODE = os.getenv('DEBUG_MODE', 'false').lower() == 'true'
DEBUG_MODE = os.getenv('DEBUG_MODE', 'false').lower() == 'true'
OPENAI_MODEL = os.getenv('OPENAI_MODEL', 'gpt-4o')
3 changes: 2 additions & 1 deletion src/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
logging.basicConfig(level=logging.DEBUG if config.DEBUG_MODE else logging.INFO)

OPENAI_API_KEY = config.OPENAI_API_KEY
OPENAI_MODEL = config.OPENAI_MODEL

client = OpenAI(
api_key=OPENAI_API_KEY,
Expand All @@ -18,7 +19,7 @@ def query_openai(prompt: str, retries=3, base_delay=1.0) -> str:
while attempt < retries:
try:
completion = client.chat.completions.create(
model="gpt-4o",
model=OPENAI_MODEL,
messages=[
{"role": "system", "content": "You are a senior software engineer at Google reviewing a pull request."},
{"role": "user", "content": prompt}
Expand Down

0 comments on commit d4d8e9c

Please sign in to comment.