This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CONTRIBUTING.md and pull request template (#429)
This should make adding new APIs clearer
- Loading branch information
1 parent
41c14c6
commit 84d2af1
Showing
3 changed files
with
40 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Thanks for submitting a pull request! Please check CONTRIBUTING.md for style guidelines. | ||
|
||
### Changes | ||
Describe your changes here | ||
|
||
### New API Checklist | ||
See CONTRIBUTING.md for more info. | ||
|
||
1. [ ] Documentation for every variable | ||
2. [ ] Class-level documentation | ||
3. [ ] POJO JSON parsing tests | ||
4. [ ] Service integration tests |
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,27 @@ | ||
# How to Contribute | ||
|
||
## How to Add a New API | ||
|
||
### Add POJOs to API library | ||
I usually have ChatGPT write them for me by copying and pasting from teh OpenAI API reference ([example chat](https://chat.openai.com/share/af48ef11-0354-40b2-a8e2-3bf8e93a94a3)), but double check everything because Chat always makes mistakes, especially around adding `@JsonProperty` annotations. | ||
|
||
- Make all java variables camel case, and use `@JsonProperty` for fields that OpenAI returns as snake case | ||
- Include comments for each variable, I take these directly from the OpenAI website | ||
- Include `@Data` on every response class, and `@Builder @NoArgsConstructor @AllArgsConstructor @Data` on every request | ||
- Include basic class-level documentation and a link to the OpenAI reference page, [example](api/src/main/java/com/theokanning/openai/threads/Thread.java) | ||
- Add a JSON test for every new java object, this ensures that your definition and variable name overrides are correct. | ||
- Copy the sample response from OpenAI into an api test [fixture](api/src/test/resources/fixtures) | ||
- Add any missing fields to the JSON file (OpenAI doesn't always include everything) | ||
- Add the class name to the test cases here [JSON test](api/src/test/java/com/theokanning/openai/JsonTest.java) | ||
|
||
### Add to [OpenAiApi](client/src/main/java/com/theokanning/openai/client/OpenAiApi.java) | ||
This is usually straightforward, use [OpenAiResponse](api/src/main/java/com/theokanning/openai/OpenAiResponse.java) for endpoints that return lists. | ||
|
||
### Add to [OpenAiService](service/src/main/java/com/theokanning/openai/OpenAiService.java) | ||
|
||
### Add an Integration Test | ||
Since 99% of the work of this library is done on OpenAI's servers, the objective of these tests is to call each endpoint at least once. | ||
Specify every available parameter to make sure that OpenAI accepts everything, but don't create extra test cases unless a parameter drastically affects the results. | ||
For example, [CompletionTest](service/src/test/java/com/theokanning/openai/service/CompletionTest.java) has one test for normal completions, and one for streaming. | ||
|
||
If your test relies on creating and retrieving external resources, [FineTuningTest](service/src/test/java/com/theokanning/openai/service/FineTuningTest.java) is a good example of how to share resources between tests and clean up afterwards. |
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