Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswebb09 committed Dec 15, 2023
1 parent 7d10ffc commit fc8fdc5
Show file tree
Hide file tree
Showing 26 changed files with 232 additions and 118 deletions.
2 changes: 2 additions & 0 deletions DirectReport/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

from DirectReport.commandline import commandline


def main():
commandline.cli()


if __name__ == "__main__":
main()
11 changes: 10 additions & 1 deletion DirectReport/browserview/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
login_manager.login_view = "login"
user_model = UserModel()


@app.route("/")
def home():
"""
Expand All @@ -34,6 +35,7 @@ def home():
"""
return render_template('index.html', title='Home')


@app.errorhandler(404)
def page_not_found(e):
"""
Expand All @@ -44,17 +46,20 @@ def page_not_found(e):
"""
return render_template('404.html', error=e), 404


@login_manager.user_loader
def user_loader(email):
user = user_model.get_user_by_email(email)
return user


@login_manager.request_loader
def request_loader(request):
email = request.form.get('email')
user = user_model.get_user_by_email(email)
return user


@app.route("/new", methods=['GET', 'POST'])
@login_required
def new():
Expand All @@ -64,6 +69,7 @@ def new():
"""
return render_template('list.html', title='New Entry', data=[])


@login_manager.unauthorized_handler
def unauthorized_handler():
if request.headers.get("X-Requested-With") == "XMLHttpRequest":
Expand All @@ -74,10 +80,12 @@ def unauthorized_handler():
else:
return redirect(url_for('auth.login'))


@app.route("/team", methods=['GET'])
def team():
return render_template('team/team.html', title='Team', data=[])


@app.route("/generate_email", methods=['POST'])
def generate_email():
prompt = ""
Expand All @@ -87,13 +95,14 @@ def generate_email():
elements = {"email": report.choices[0].message.content}
return elements, 201


@app.route("/repo/<reponame>", methods=['GET'])
def repo(reponame=None):

client = GithubClient()
repo = client.get_repo_issues("chriswebb09", reponame)
print(repo)
return render_template('team/team.html', title='Team', data=[])


if __name__ == "__main__":
app.run(debug=True, port=5000)
21 changes: 10 additions & 11 deletions DirectReport/browserview/auth/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

user_model = UserModel()


@auth.route('/signup', methods=['POST', 'GET'])
def signup():
if request.method == 'POST':
Expand All @@ -27,12 +28,14 @@ def signup():
return redirect(url_for('auth.login'))
return render_template('auth/signup.html')


@auth.route('/logout')
@login_required
def logout():
logout_user()
return redirect(url_for('reportsbp.team_report'))


@auth.route('/login', methods=['POST', 'GET'])
def login():
if request.method == 'POST':
Expand All @@ -49,11 +52,13 @@ def login():
flash("Please check your login details and try again.")
return render_template('auth/login.html')


@auth.route("/account", methods=['GET', 'POST'])
@login_required
def account():
return render_template('account.html', title='Account', name=current_user.username, userid=current_user.id)


@auth.route("/account_data", methods=['GET'])
@login_required
def account_data():
Expand All @@ -63,22 +68,16 @@ def account_data():
shortlog = client.parse_git_shortlog(logitem)
report_results = []
for report in saved_reports:
report_element = {
"report": report
}
report_element = {"report": report}
report_results.append(report_element)

user_account = {
user_account = {
"name": current_user.firstname + " " + current_user.lastname,
"firstname": current_user.firstname,
"lastname": current_user.lastname,
"userid": current_user.id,
"username": current_user.username,
"email": current_user.email
}
user_element = {
"user": user_account,
"reports": report_results,
"shortlog": shortlog
"email": current_user.email,
}
return user_element, 201
user_element = {"user": user_account, "reports": report_results, "shortlog": shortlog}
return user_element, 201
8 changes: 3 additions & 5 deletions DirectReport/browserview/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,21 @@ def get_repo_issues(self, repo_owner, repo_name):
response.raise_for_status()
return response.json()

class HuggingFaceClient:

class HuggingFaceClient:
def query(self, payload):
API_URL = "https://api-inference.huggingface.co/models/meta-llama/Llama-2-7b-chat-hf"
headers = {"Authorization": "Bearer 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"}
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()

class GoogleAIClient:


class GoogleAIClient:
def query(self, prompt):
API_URL = f"https://generativelanguage.googleapis.com/v1beta3/models/text-bison-001:generateText?key={appsecrets.GOOGLE_AI_TOKEN}"
headers = {"Content-Type": "application/json"}
prompt_data = prompts.GENERATE_SUMMARY_PROMPT_PREIX + prompt
data = {"prompt": { "text": f"{prompt_data}"}}
data = {"prompt": {"text": f"{prompt_data}"}}
response = requests.post(API_URL, data=json.dumps(data), headers=headers)
data = json.loads(response.text)
return data
Expand All @@ -105,4 +104,3 @@ def get_data_from(self, prompt):
response = self.query(prompt)
response_data = response["candidates"][0]["output"]
return response_data

121 changes: 81 additions & 40 deletions DirectReport/browserview/modelclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,30 @@
{
"name": "Adrian Prantl",
"accomplishments": "Adrian made significant contributions to the DebugInfo and SILGen, including adding support for debug info for coroutine alloc as,inlined and specialized generic variables.He also worked on the mangling testcase,fixed source locations of variable assignments and function calls, and added build-script support for SwiftLLDB backwards-compatibility tests.",
"commits": "67"
"commits": "67",
},
{
"name": "Alan Zeino",
"accomplishments": "Alan fixed a typo in the code example in libSyntax README.",
"commits": "1"
"commits": "1",
},
{
"name": "Alejandro",
"accomplishments": "Alejandro removed awarning, made some documentation fixes, fixed Binary Floating Point. random(in:) open range returning upperBound, and fixed a minor code typo in SILPro.",
"commits": "3"
},
{
"name": "Akshay Shrimali",
"accomplishments": "Akshay updated the README.md file.",
"commits": "1"
"commits": "3",
},
{"name": "Akshay Shrimali", "accomplishments": "Akshay updated the README.md file.", "commits": "1"},
{
"name": "Ahmad Alhashemi",
"accomplishments": "Ahmad worked on the Parser, detecting non breaking space U+00A0 and providing a fix.He also made minor style edits and added more non-breaking space testcases.",
"commits": "5"
},
{
"name": "Albin Sadowski",
"accomplishments": "Albin fixed syntax highlighting in CHANGELOG.",
"commits": "1"
"commits": "5",
},
{"name": "Albin Sadowski", "accomplishments": "Albin fixed syntax highlighting in CHANGELOG.", "commits": "1"},
{
"name": "Alex Blewitt",
"accomplishments": "Alex worked on several fixes including compare for lhs and rhs, using || instead of && for kind comparison,removing duplicate conditional check and duplicate if statement.",
"commits": "5"
}
"commits": "5",
},
],
"report": {
"summary": "The team made significant progress this week with a total of 83 commits.The main focus was on DebugInfo and SILGen enhancements, Parser improvements, and various fixes.",
Expand All @@ -51,18 +43,18 @@
"highlights": [
{
"title": "DebugInfo and SILGen Enhancements",
"description": "Adrian Prantl made significant contributions to the DebugInfo and SILGen, including adding support for debuginfo for coroutine allocas, inlined and specialized generic variables."
"description": "Adrian Prantl made significant contributions to the DebugInfo and SILGen, including adding support for debuginfo for coroutine allocas, inlined and specialized generic variables.",
},
{
"title": "Parser Improvements",
"description": "Ahmad Alhashemi worked on the Parser,detecting non breaking space U+00A0 and providing a fix."
"description": "Ahmad Alhashemi worked on the Parser,detecting non breaking space U+00A0 and providing a fix.",
},
{
"title": "Various Fixes",
"description": "The team worked on several fixes including compare for lhs and rhs, using || instead of && for kind comparison,removing duplicate conditional check and duplicate if statement."
}
"description": "The team worked on several fixes including compare for lhs and rhs, using || instead of && for kind comparison,removing duplicate conditional check and duplicate if statement.",
},
],
"conclusion": "The team demonstrated good progress this week, with a focus on enhancing DebugInfo and SILGen, improving the Parser, and implementing various fixes. The team should continue to focus on these areas in the coming week."
"conclusion": "The team demonstrated good progress this week, with a focus on enhancing DebugInfo and SILGen, improving the Parser, and implementing various fixes. The team should continue to focus on these areas in the coming week.",
},
"broad_categories": {
"debug_info": 16,
Expand All @@ -71,34 +63,83 @@
"test_related": 6,
"nonbreaking_space_handling": 5,
"readme_update": 1,
"syntax_fix": 1
}

"syntax_fix": 1,
},
}

RAW_REPORT_DATA_2 = {"report": {
"broad_categories": {"code_maintenance": 9, "debug_info": 16, "documentation": 7, "nonbreaking_space_handling": 5, "readme_update": 1, "syntax_fix": 1, "test_related": 6},

RAW_REPORT_DATA_2 = {
"report": {
"broad_categories": {
"code_maintenance": 9,
"debug_info": 16,
"documentation": 7,
"nonbreaking_space_handling": 5,
"readme_update": 1,
"syntax_fix": 1,
"test_related": 6,
},
"report": {
"areas_of_focus": ['DebugInfo and SILGen Enhancements', 'Parser Improvements', 'Various Fixes'],
"conclusion": 'The team demonstrated good progress this week, with a focus on enhancing DebugInfo and SILGen, improving the Parser, and implementing various fixes. The team should continue to focus on these areas in the coming week.',
"highlights": [
{"description": 'Adrian Prantl made significant contributions to the DebugInfo and SILGen, including adding support for debuginfo for coroutine allocas, inlined and specialized generic variables.', 'title': 'DebugInfo and SILGen Enhancements'},
{"description": 'Ahmad Alhashemi worked on the Parser, detecting non-breaking space U+00A0 and providing a fix.', 'title': 'Parser Improvements'},
{"description": 'The team worked on several fixes including compare for lhs and rhs, using || instead of && for kind comparison, removing duplicate conditional check and duplicate if statement.', 'title': 'Various Fixes'}
{
"description": 'Adrian Prantl made significant contributions to the DebugInfo and SILGen, including adding support for debuginfo for coroutine allocas, inlined and specialized generic variables.',
'title': 'DebugInfo and SILGen Enhancements',
},
{
"description": 'Ahmad Alhashemi worked on the Parser, detecting non-breaking space U+00A0 and providing a fix.',
'title': 'Parser Improvements',
},
{
"description": 'The team worked on several fixes including compare for lhs and rhs, using || instead of && for kind comparison, removing duplicate conditional check and duplicate if statement.',
'title': 'Various Fixes',
},
],
'summary': 'The team made significant progress this week with a total of 83 commits. The main focus was on DebugInfo and SILGen enhancements, Parser improvements, and various fixes.',
'total_commits': '83'
'total_commits': '83',
},
"shortlog": {
'Adrian Prantl': 67,
'Ahmad Alhashemi': 5,
'Akshay Shrimali': 1,
'Alan Zeino': 1,
'Albin Sadowski': 1,
'Alejandro': 3,
'Alex Blewitt': 5,
},
"shortlog": {'Adrian Prantl': 67, 'Ahmad Alhashemi': 5, 'Akshay Shrimali': 1, 'Alan Zeino': 1, 'Albin Sadowski': 1, 'Alejandro': 3, 'Alex Blewitt': 5},
"team": [
{'accomplishments': 'Adrian made significant contributions to the DebugInfo and SILGen, including adding support for debug info for coroutine allocas, inlined and specialized generic variables. He also worked on the mangling testcase, fixed source locations of variable assignments and function calls, and added build-script support for Swift LLDB backwards-compatibility tests.', 'commits': '67', 'name': 'Adrian Prantl'},
{'accomplishments': 'Alan fixed a typo in the code example in libSyntax README.', 'commits': '1', 'name': 'Alan Zeino'},
{'accomplishments': 'Alejandro removed a warning, made some documentation fixes, fixed Binary Floating Point. random(in:) open range returning upperBound, and fixed a minor code typo in SILPro.', 'commits': '3', 'name': 'Alejandro'},
{
'accomplishments': 'Adrian made significant contributions to the DebugInfo and SILGen, including adding support for debug info for coroutine allocas, inlined and specialized generic variables. He also worked on the mangling testcase, fixed source locations of variable assignments and function calls, and added build-script support for Swift LLDB backwards-compatibility tests.',
'commits': '67',
'name': 'Adrian Prantl',
},
{
'accomplishments': 'Alan fixed a typo in the code example in libSyntax README.',
'commits': '1',
'name': 'Alan Zeino',
},
{
'accomplishments': 'Alejandro removed a warning, made some documentation fixes, fixed Binary Floating Point. random(in:) open range returning upperBound, and fixed a minor code typo in SILPro.',
'commits': '3',
'name': 'Alejandro',
},
{'accomplishments': 'Akshay updated the README.md file.', 'commits': '1', 'name': 'Akshay Shrimali'},
{'accomplishments': 'Ahmad worked on the Parser, detecting non-breaking space U+00A0 and providing a fix. He also made minor style edits and added more non-breaking space testcases.', 'commits': '5', 'name': 'Ahmad Alhashemi'},
{'accomplishments': 'Albin fixed syntax highlighting in CHANGELOG.', 'commits': '1', 'name': 'Albin Sadowski'},
{'accomplishments': 'Alex worked on several fixes including compare for lhs and rhs, using || instead of && for kind comparison, removing duplicate conditional check and duplicate if statement.', 'commits': '5', 'name': 'Alex Blewitt'}
]
{
'accomplishments': 'Ahmad worked on the Parser, detecting non-breaking space U+00A0 and providing a fix. He also made minor style edits and added more non-breaking space testcases.',
'commits': '5',
'name': 'Ahmad Alhashemi',
},
{
'accomplishments': 'Albin fixed syntax highlighting in CHANGELOG.',
'commits': '1',
'name': 'Albin Sadowski',
},
{
'accomplishments': 'Alex worked on several fixes including compare for lhs and rhs, using || instead of && for kind comparison, removing duplicate conditional check and duplicate if statement.',
'commits': '5',
'name': 'Alex Blewitt',
},
],
},
'created_at': '1702314769.558132'}
'created_at': '1702314769.558132',
}
19 changes: 7 additions & 12 deletions DirectReport/browserview/prompt_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,21 @@
from DirectReport.datadependencies import appsecrets, prompts

openai.api_key = appsecrets.SECRET_KEY


def generate_email(data):
prompt = prompts.GENERATE_EMAIL_PROMPT_PREFIX + data
message=[{"role": "user", "content": prompt}]
message = [{"role": "user", "content": prompt}]
response = openai.ChatCompletion.create(
model="gpt-4",
messages = message,
temperature=0.1,
max_tokens=1000,
frequency_penalty=0.0
model="gpt-4", messages=message, temperature=0.1, max_tokens=1000, frequency_penalty=0.0
)
return response


def get_team_summarys_from_git_shortlog(data):
prompt = prompts.GENERATE_SUMMARY_PROMPT_PREIX + data
message=[{"role": "user", "content": prompt}]
message = [{"role": "user", "content": prompt}]
response = openai.ChatCompletion.create(
model="gpt-4",
messages = message,
temperature=0,
max_tokens=1000,
frequency_penalty=0.0
model="gpt-4", messages=message, temperature=0, max_tokens=1000, frequency_penalty=0.0
)
return response
Loading

0 comments on commit fc8fdc5

Please sign in to comment.