-
Notifications
You must be signed in to change notification settings - Fork 2
Initial issue doc #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
mtabacman
wants to merge
17
commits into
release-candidate
Choose a base branch
from
#6-improve-docs
base: release-candidate
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 7 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c812dc4
Initial issue doc
mtabacman a8430dc
Generate example files
mtabacman 49d9e89
More detail on created files
mtabacman 5f7855c
Correct example file format
mtabacman 5a757bc
Use better file generation for all examples
mtabacman cd70c11
List all examples
mtabacman ee84251
Document how to use some examples
mtabacman 90a866c
Completed example explanation
mtabacman 1413441
Rewritten example
mtabacman ed53f45
Removed trailing space
mtabacman 55ba9d9
Initial Files API reference
mtabacman b2bbb13
Completed Files API reference
mtabacman 20fdb81
Initial Answers API reference
mtabacman d876a84
Rework API to consider deprecations
mtabacman f38c24e
Starting with fine tune API
mtabacman 69533af
Completed (incorrect) example using Fine Tune API
mtabacman ee54964
Completed fine tune example
mtabacman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,111 @@ | ||
# How to run the examples | ||
|
||
## How to generate the example files | ||
|
||
In order to use the examples provided in `OpenAIExamples`, | ||
you'll need to have some examples files available locally. | ||
|
||
To create all required files you can execute: | ||
|
||
```smalltalk | ||
OpenAIExamples new generateExampleFiles | ||
``` | ||
|
||
This will create, inside the *open-ai* directory: | ||
|
||
- answers-example.jsonl | ||
- classifications-example.jsonl | ||
- file-that-will-be-deleted.jsonl | ||
- fine-tune-example.jsonl | ||
- search-example.jsonl | ||
|
||
## How to configure your API key | ||
|
||
Before running the examples, you must provide a valid API key. | ||
|
||
1. [Sign up](https://beta.openai.com/signup) for an OpenAI account. | ||
|
||
2. Go to your | ||
[API keys]( | ||
https://beta.openai.com/account/api-keys | ||
) | ||
and click on the *Create new secret key* button. | ||
|
||
3. Click on the *Copy* link next to your recently created key. | ||
|
||
4. Create a file named *apikey.secret* in the *open-ai* directory. | ||
|
||
5. Paste the copied key into the file, then save it. | ||
|
||
## How to invoke the APIs with the examples | ||
|
||
Several examples are provided which show a possible use case for the diferent APIs. | ||
|
||
The example methods return an object that extract the relevant answer | ||
from the full API respose. | ||
This is intended for the examples to illustrate how to navigate the structure | ||
of the responses of the different APIs wrapped. | ||
|
||
### Files API | ||
|
||
Examples using the [Files API](https://beta.openai.com/docs/api-reference/files) | ||
|
||
OpenAI offers by default 1 GB storage *per organization*. | ||
For individual users this means 1 GB as well. | ||
There is no cost associated with managing files. | ||
This means that running the examples in this section will not reduce | ||
your free balance. | ||
|
||
Files are uploaded asynchronously. | ||
Uploading returns a *File ID* than can be used later to check the file status. | ||
You can't use a file until it's status is **processed**. | ||
|
||
All uploads in the examples will wait up to 20 seconds, polling every second, | ||
until the upload is complete. | ||
|
||
Running `OpenAIExamples new files` will list the files currently registered. | ||
In case you have not yet made any upload, the example will upload `open-ai/fine-tune-example.jsonl`. | ||
|
||
Running `OpenAIExamples new downloadAndRemoveFile` will upload `open-ai/file-that-will-be-deleted.jsonl`. | ||
After uploading is complete, the file will be deleted. | ||
This is just meant to show the steps to both upload and delete a file. | ||
|
||
Running `OpenAIExamples new deleteAllFiles` will **delete all files** | ||
declared to your OpenAI account. | ||
**Always use this example with caution**. | ||
|
||
### Answers API | ||
|
||
Examples using the [Answers API](https://beta.openai.com/docs/api-reference/answers) | ||
|
||
Running `OpenAIExamples new answers` will ask *where is France?'* | ||
using as context the information `France is in Europe` and | ||
`Canada is in America` and `Japan is in Asia`. | ||
To explain to OpenAI how to extract information from context, | ||
it will provide the example that given the context `this car is 2 meters long` | ||
and the question `how long is this car` the answer should be `2 meters`. | ||
This use case does not employ the Files API, all processing is done in the moment. | ||
|
||
Running `OpenAIExamples new answersFromFile` will do the same, | ||
but the context is provided by the file `answers-example.jsonl`. | ||
The file is uploaded, and then the question is asked to OpenAI. | ||
|
||
### Search API | ||
|
||
Examples using the [Search API](https://beta.openai.com/docs/api-reference/searches) | ||
OpenAIExamples new search . | ||
OpenAIExamples new searchFromFile . | ||
|
||
### Completions API | ||
|
||
Examples using the [Completions API](https://beta.openai.com/docs/api-reference/completions) | ||
OpenAIExamples new completions . | ||
|
||
### Classifications API | ||
|
||
Examples using the [Classifications API](https://beta.openai.com/docs/api-reference/classifications) | ||
|
||
OpenAIExamples new classifications . | ||
OpenAIExamples new classificationsFromFileWithoutLabels . | ||
OpenAIExamples new classificationsFromFile . | ||
|
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.