Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 3c129d6

Browse files
committed
initial implementation
1 parent e2f6ce8 commit 3c129d6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2552096
-7905
lines changed

.dockerignore

-12
This file was deleted.

.env.example

-9
This file was deleted.

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
lib

.eslintrc

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": {
5+
"project": "./tsconfig.json"
6+
},
7+
"plugins": ["@typescript-eslint"],
8+
"extends": [
9+
"eslint:recommended",
10+
"plugin:@typescript-eslint/eslint-recommended",
11+
"plugin:@typescript-eslint/recommended"
12+
],
13+
"rules": {
14+
"@typescript-eslint/no-floating-promises": "error",
15+
"@typescript-eslint/no-misused-promises": "error",
16+
"@typescript-eslint/no-explicit-any": 0,
17+
"@typescript-eslint/no-unused-vars": 0,
18+
"@typescript-eslint/ban-ts-comment": 0
19+
}
20+
}

.gitignore

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
node_modules
2-
npm-debug.log
3-
*.pem
4-
!mock-cert.pem
5-
.env
6-
coverage
72
lib
3+
.gpte

.husky/pre-commit

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx pretty-quick --staged
5+

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"tabWidth": 2,
3+
"printWidth": 100
4+
}

.vscode/settings.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"editor.defaultFormatter": "esbenp.prettier-vscode",
3+
"editor.formatOnSave": true
4+
}

CODEOWNERS

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# For more information, see [docs](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-syntax)
2+
3+
# This repository is maintained by:
4+
5+
- @dsyme @wunderalbert @johanrosenkilde

CODE_OF_CONDUCT.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ In the interest of fostering an open and welcoming environment, we as
66
contributors and maintainers pledge to making participation in our project and
77
our community a harassment-free experience for everyone, regardless of age, body
88
size, disability, ethnicity, gender identity and expression, level of experience,
9-
education, socio-economic status, nationality, personal appearance, race,
10-
religion, or sexual identity and orientation.
9+
nationality, personal appearance, race, religion, or sexual identity and
10+
orientation.
1111

1212
## Our Standards
1313

@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
5555
## Enforcement
5656

5757
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58-
reported by contacting the project team at . All
58+
reported by contacting the project team at [email protected]. All
5959
complaints will be reviewed and investigated and will result in a response that
6060
is deemed necessary and appropriate to the circumstances. The project team is
6161
obligated to maintain confidentiality with regard to the reporter of an incident.
@@ -68,6 +68,7 @@ members of the project's leadership.
6868
## Attribution
6969

7070
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71-
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
71+
available at [http://contributor-covenant.org/version/1/4][version]
7272

73-
[homepage]: https://www.contributor-covenant.org
73+
[homepage]: http://contributor-covenant.org
74+
[version]: http://contributor-covenant.org/version/1/4/

CONTRIBUTING.md

+2-28
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,10 @@
11
## Contributing
22

3-
[fork]: /fork
4-
[pr]: /compare
5-
[code-of-conduct]: CODE_OF_CONDUCT.md
6-
73
Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
84

9-
Please note that this project is released with a [Contributor Code of Conduct][code-of-conduct]. By participating in this project you agree to abide by its terms.
10-
11-
## Issues and PRs
12-
13-
If you have suggestions for how this project could be improved, or want to report a bug, open an issue! We'd love all and any contributions. If you have questions, too, we'd love to hear them.
14-
15-
We'd also love PRs. If you're thinking of a large PR, we advise opening up an issue first to talk about it, though! Look at the links below if you're not sure how to open a PR.
16-
17-
## Submitting a pull request
18-
19-
1. [Fork][fork] and clone the repository.
20-
1. Configure and install the dependencies: `npm install`.
21-
1. Make sure the tests pass on your machine: `npm test`, note: these tests also apply the linter, so there's no need to lint separately.
22-
1. Create a new branch: `git checkout -b my-branch-name`.
23-
1. Make your change, add tests, and make sure the tests still pass.
24-
1. Push to your fork and [submit a pull request][pr].
25-
1. Pat your self on the back and wait for your pull request to be reviewed and merged.
26-
27-
Here are a few things you can do that will increase the likelihood of your pull request being accepted:
28-
29-
- Write and update tests.
30-
- Keep your changes as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
31-
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
5+
This project is primarily for reference for the GitHub Next investigation it describes. Please contribute corrections.
326

33-
Work in Progress pull requests are also welcome to get feedback early on, or if there is something blocked you.
7+
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
348

359
## Resources
3610

Dockerfile

-8
This file was deleted.

LICENSE

-15
This file was deleted.

LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright GitHub
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+51-16
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,68 @@
1-
# changepilot-bot
1+
# GPT-4 Equipped with Numeric Calculation
22

3-
> A GitHub App built with [Probot](https://github.com/probot/probot) that A bot that turns GitHub Issues into PRs
3+
GPT-4 has trouble with calculating with numbers. We look at a technique to fix that.
44

5-
## Setup
5+
[**Read the report - GPT-4 Equipped with Numeric Calculation**](docs/report.md)
6+
7+
[**Read the evaluation**](docs/eval.md)
8+
9+
> NOTE: The default model used when running this code is OpenAI's **`text-davinci-003`** and not GPT-4. The code can be adjusted to run against any completion API by changing the settings in [`src/engine/options.ts`](src/engine/options.ts) and [`src/engine/settings.ts`](src/engine/settings.ts).
10+
>
11+
> When writing this report, we evaluated the technique using the completion API of a private release of GPT-4. The public release of GPT-4 currently only provides a "chat" API. As a result some aspects of the technique described may need to be reworked because of this, hwoever we are providing the code and our investigation for reference. We believe the evaluation results remain valid although some variation in numbers is to be expected.
12+
13+
## Requirements
614

715
```sh
8-
# Install dependencies
16+
sudo apt-get install npm
917
npm install
18+
npm run build
19+
```
1020

11-
# Run the bot
12-
npm start
21+
## Examples
22+
23+
Define an API key:
24+
25+
```bash
26+
export OPENAI_API_KEY=...
1327
```
1428

15-
## Docker
29+
Try your own question:
1630

17-
```sh
18-
# 1. Build container
19-
docker build -t changepilot-bot .
31+
```bash
32+
./gpte ask --question "What is sin(13.31) where the input is in degrees?"
33+
./gpte ask --question "What is sin(13.31) where the input is in degrees?" --arith
2034

21-
# 2. Start container
22-
docker run -e APP_ID=<app-id> -e PRIVATE_KEY=<pem-value> changepilot-bot
35+
./gpte ask --questionfile test/samples/number-years-grow-30.txt
36+
./gpte ask --questionfile test/samples/number-years-grow-30.txt --arith
2337
```
2438

25-
## Contributing
39+
These examples require GPT-4 token window size, code generation and reasoning:
40+
41+
```bash
42+
./gpte ask --questionfile test/samples/msft-report-snippet.txt
43+
./gpte ask --questionfile test/samples/msft-report-snippet.txt --arith
2644

27-
If you have suggestions for how changepilot-bot could be improved, or want to report a bug, open an issue! We'd love all and any contributions.
45+
./gpte ask --questionfile test/samples/msft-goog-report-snippets-compared.txt
46+
./gpte ask --questionfile test/samples/msft-goog-report-snippets-compared.txt --arith
2847

29-
For more, check out the [Contributing Guide](CONTRIBUTING.md).
48+
./gpte ask --questionfile test/samples/gap-lulemon-financial-reports-compared.txt
49+
./gpte ask --questionfile test/samples/gap-lulemon-financial-reports-compared.txt --arith
50+
```
51+
52+
With an appropriate model, entire problem sets can be evaluated using `./gpte eval`.
3053

3154
## License
3255

33-
[ISC](LICENSE) © 2022 Matt Rothenberg
56+
This project is licensed under the terms of the MIT open source license. Please refer to [MIT](./LICENSE.txt) for the full terms.
57+
58+
## Maintainers
59+
60+
Maintainers: @dsyme, @wunderalbert, @johanrosenkilde
61+
62+
## Support
63+
64+
This project is a concluded technical investigation by GitHub Next. It is provided for reference.
65+
66+
## Acknowledgement
67+
68+
This project includes a modified version of the [`ASDiv.xml` dataset](https://github.com/chaochun/nlu-asdiv-dataset/blob/master/dataset/ASDiv.xml) for numeric calculation problems, adapted primarily to clarify the precisions and formats required in answers, see the [evaluation](docs/eval.md).

SECURITY.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Thanks for helping make GitHub safe for everyone.
2+
3+
# Security
4+
5+
GitHub takes the security of our software products and services seriously, including all of the open source code repositories managed through our GitHub organizations, such as [GitHub](https://github.com/GitHub).
6+
7+
Even though [open source repositories are outside of the scope of our bug bounty program](https://bounty.github.com/index.html#scope) and therefore not eligible for bounty rewards, we will ensure that your finding gets passed along to the appropriate maintainers for remediation.
8+
9+
## Reporting Security Issues
10+
11+
If you believe you have found a security vulnerability in any GitHub-owned repository, please report it to us through coordinated disclosure.
12+
13+
**Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.**
14+
15+
Instead, please send an email to opensource-security[@]github.com.
16+
17+
Please include as much of the information listed below as you can to help us better understand and resolve the issue:
18+
19+
- The type of issue (e.g., buffer overflow, SQL injection, or cross-site scripting)
20+
- Full paths of source file(s) related to the manifestation of the issue
21+
- The location of the affected source code (tag/branch/commit or direct URL)
22+
- Any special configuration required to reproduce the issue
23+
- Step-by-step instructions to reproduce the issue
24+
- Proof-of-concept or exploit code (if possible)
25+
- Impact of the issue, including how an attacker might exploit the issue
26+
27+
This information will help us triage your report more quickly.
28+
29+
## Policy
30+
31+
See [GitHub's Safe Harbor Policy](https://docs.github.com/en/github/site-policy/github-bug-bounty-program-legal-safe-harbor#1-safe-harbor-terms)

SUPPORT.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Support
2+
3+
## How to file issues and get help
4+
5+
This project uses GitHub issues to track bugs and feature requests. Please search the existing issues before filing new issues to avoid duplicates. For new issues, file your bug or feature request as a new issue.
6+
7+
For help or questions about using this project, please file an issue.
8+
9+
"gpt4-with-calc" is a reference implementation of the technique described in the report and is not actively developed but is maintained by GitHub staff. We will do our best to respond to support and community questions in a timely manner.
10+
11+
## GitHub Support Policy
12+
13+
Support for this project is limited to the resources listed above.

0 commit comments

Comments
 (0)