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

Sync sonnet changes #10

Merged
merged 5 commits into from
Jul 29, 2024
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
.lsp/
.vscode/
venv/
lib/
bin/
pr_agent/settings/.secrets.toml
__pycache__
dist/
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ ENV PYTHONPATH=/app

FROM base as github_app
ADD pr_agent pr_agent
CMD ["python", "-m", "gunicorn", "-k", "uvicorn.workers.UvicornWorker", "-c", "pr_agent/servers/gunicorn_config.py", "--forwarded-allow-ips", "*", "pr_agent.servers.github_app:app"]

CMD ["python", "pr_agent/servers/launch_github_app.py"]

FROM base as bitbucket_app
ADD pr_agent pr_agent
Expand Down
5 changes: 5 additions & 0 deletions pr_agent/servers/github_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import re
import uuid
from typing import Any, Dict, Tuple
import boto3
import json
import toml
from botocore.exceptions import ClientError

import uvicorn
from fastapi import APIRouter, FastAPI, HTTPException, Request, Response
Expand All @@ -23,6 +27,7 @@
from pr_agent.log import LoggingFormat, get_logger, setup_logger
from pr_agent.servers.utils import DefaultDictWithTimeout, verify_signature


setup_logger(fmt=LoggingFormat.JSON, level="DEBUG")
base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
build_number_path = os.path.join(base_path, "build_number.txt")
Expand Down
39 changes: 39 additions & 0 deletions pr_agent/servers/launch_github_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import subprocess
import re
import boto3
import json
import toml
from botocore.exceptions import ClientError

secret_name = "devops/github/pr-agent-bot"
region_name = "eu-west-1"

def get_aws_secrets(secret_name, region_name):
session = boto3.session.Session()
client = session.client(
service_name='secretsmanager',
region_name=region_name
)

try:
get_secret_value_response = client.get_secret_value(
SecretId=secret_name
)
except ClientError as e:
raise e

secret = get_secret_value_response['SecretString']
return secret

def create_toml_file(file_path, secret_content):
try:
with open("pr_agent/settings/.secrets.toml", 'w') as file:
file.write(secret_content)
print(f"Successfully updated in {file_path}.")
except Exception as e:
print(f"Error writing to TOML file: {e}")

secret_dict = json.loads(get_aws_secrets(secret_name,region_name))
secret_toml=secret_dict.get('secret_file')
create_toml_file("pr_agent/settings/.secrets.toml",secret_toml)
subprocess.run(['python', 'pr_agent/servers/github_app.py'])
92 changes: 92 additions & 0 deletions pr_agent/settings/.secrets_template_bkp.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# QUICKSTART:
# Copy this file to .secrets.toml in the same folder.
# The minimum workable settings - set openai.key to your API key.
# Set github.deployment_type to "user" and github.user_token to your GitHub personal access token.
# This will allow you to run the CLI scripts in the scripts/ folder and the github_polling server.
#
# See README for details about GitHub App deployment.

[openai]
key = "" # Acquire through https://platform.openai.com
#org = "<ORGANIZATION>" # Optional, may be commented out.
# Uncomment the following for Azure OpenAI
#api_type = "azure"
#api_version = '2023-05-15' # Check Azure documentation for the current API version
#api_base = "" # The base URL for your Azure OpenAI resource. e.g. "https://<your resource name>.openai.azure.com"
#deployment_id = "" # The deployment name you chose when you deployed the engine
#fallback_deployments = [] # For each fallback model specified in configuration.toml in the [config] section, specify the appropriate deployment_id

[pinecone]
api_key = "..."
environment = "gcp-starter"

[anthropic]
key = "" # Optional, uncomment if you want to use Anthropic. Acquire through https://www.anthropic.com/

[cohere]
key = "" # Optional, uncomment if you want to use Cohere. Acquire through https://dashboard.cohere.ai/

[replicate]
key = "" # Optional, uncomment if you want to use Replicate. Acquire through https://replicate.com/

[groq]
key = "" # Acquire through https://console.groq.com/keys

[huggingface]
key = "" # Optional, uncomment if you want to use Huggingface Inference API. Acquire through https://huggingface.co/docs/api-inference/quicktour
api_base = "" # the base url for your huggingface inference endpoint

[ollama]
api_base = "" # the base url for your local Llama 2, Code Llama, and other models inference endpoint. Acquire through https://ollama.ai/

[vertexai]
vertex_project = "" # the google cloud platform project name for your vertexai deployment
vertex_location = "" # the google cloud platform location for your vertexai deployment

[aws]
bedrock_region = "" # the AWS region to call Bedrock APIs

[github]
# ---- Set the following only for deployment type == "user"
user_token = "" # A GitHub personal access token with 'repo' scope.
deployment_type = "user" #set to user by default

# ---- Set the following only for deployment type == "app", see README for details.
private_key = """\
-----BEGIN RSA PRIVATE KEY-----
<GITHUB PRIVATE KEY>
-----END RSA PRIVATE KEY-----
"""
app_id = 123456 # The GitHub App ID, replace with your own.
webhook_secret = "<WEBHOOK SECRET>" # Optional, may be commented out.

[gitlab]
# Gitlab personal access token
personal_access_token = ""

[bitbucket]
# For Bitbucket personal/repository bearer token
bearer_token = ""

[bitbucket_server]
# For Bitbucket Server bearer token
auth_token = ""
webhook_secret = ""

# For Bitbucket app
app_key = ""
base_url = ""

[litellm]
LITELLM_TOKEN = "" # see https://docs.litellm.ai/docs/debugging/hosted_debugging for details and instructions on how to get a token

[azure_devops]
# For Azure devops personal access token
org = ""
pat = ""

[azure_devops_server]
# For Azure devops Server basic auth - configured in the webhook creation
# Optional, uncomment if you want to use Azure devops webhooks. Value assinged when you create the webhook
# webhook_username = "<basic auth user>"
# webhook_password = "<basic auth password>"
2 changes: 1 addition & 1 deletion pr_agent/settings/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ final_update_message = false

[github]
# The type of deployment to create. Valid values are 'app' or 'user'.
deployment_type = "user"
deployment_type = "app"
ratelimit_retries = 5
base_url = "https://api.github.com"
publish_inline_comments_fallback_with_verification = true
Expand Down
5 changes: 5 additions & 0 deletions pyvenv.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
home = /usr/local/opt/[email protected]/bin
include-system-site-packages = false
version = 3.12.3
executable = /usr/local/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/bin/python3.12
command = /usr/local/opt/[email protected]/bin/python3.12 -m venv /Users/amar.khan/pr-agent
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ tiktoken==0.7.0
ujson==5.8.0
uvicorn==0.22.0
tenacity==8.2.3
toml==0.10.2
gunicorn==20.1.0
# Uncomment the following lines to enable the 'similar issue' tool
# pinecone-client
Expand Down