-
Notifications
You must be signed in to change notification settings - Fork 330
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (22 loc) · 913 Bytes
/
main.py
File metadata and controls
33 lines (22 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import flask
import functions_framework
from bugbug import generative_model_tool
from bugbug.tools.release_notes import ReleaseNotesCommitsSelector
tool: ReleaseNotesCommitsSelector | None = None
DEFAULT_CHUNK_SIZE = 1000
@functions_framework.http
def handle_release_notes(request: flask.Request):
global tool
if request.method != "GET":
return "Only GET requests are allowed", 405
release = int(request.args.get("release"))
channel = request.args.get("channel")
if not release or not channel:
return "Missing 'release' or 'channel' query parameter", 400
if tool is None:
llm = generative_model_tool.create_openai_llm()
tool = ReleaseNotesCommitsSelector(chunk_size=DEFAULT_CHUNK_SIZE, llm=llm)
commit_list = tool.get_final_release_notes_commits(
target_release=release, channel=channel
)
return {"commits": commit_list}, 200