-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
# ![pull-merge](/logo/svg/logo-no-background.svg) | ||
|
||
puLL-Merge is a `github-action` to add LLM capabilities to pull-requests in `github` automatically | ||
|
||
## Example (local) | ||
|
||
``` | ||
./run.js ./src/explainPatch.js --openaiKey=<OPENAPI_KEY> --repo=brave/security-action --prnum=406 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env node | ||
|
||
import { parseArgs } from 'node:util'; | ||
const [ node, file, _module, ...args ] = process.argv; | ||
|
||
const run = (await import(_module)).default; | ||
const innerArgs = parseArgs({args, strict: false}); | ||
|
||
console.log(await run(innerArgs.values)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import OpenAI from "openai"; | ||
|
||
export default async function explainPatch({openaiKey, repo, prnum, | ||
model="gpt-3.5-turbo-16k", | ||
system_prompt="Explain the patch:\n\n", | ||
max_tokens=256, | ||
temperature=1, | ||
top_p=1, | ||
frequency_penalty=0, | ||
presence_penalty=0}) { | ||
const openai = new OpenAI({apiKey: openaiKey}); | ||
|
||
const patchResponse = await fetch(`https://github.com/${repo}/pull/${prnum}.patch`); | ||
const patchBody = await patchResponse.text(); | ||
|
||
// console.log(patchBody) | ||
|
||
const aiResponse = await openai.chat.completions.create({ | ||
model: model, | ||
messages: [ | ||
{ | ||
"role": "system", | ||
"content": "Explain the patch:\n\n" | ||
}, | ||
{ | ||
"role": "user", | ||
"content": patchBody | ||
} | ||
], | ||
temperature: temperature, | ||
max_tokens: max_tokens, | ||
top_p: top_p, | ||
frequency_penalty: frequency_penalty, | ||
presence_penalty: presence_penalty, | ||
}); | ||
|
||
// console.log(aiResponse); | ||
// console.log(aiResponse.choices[0].message); | ||
|
||
return aiResponse.choices[0].message.content; | ||
} |