Github Action to easily integrate OpenAI's API (Chat+Completions) into workflows. Empower your project with OpenAI's language model for intelligent response generation in just a few steps.
This project is a wrapper around the OpenAI's NodeJS SDK.
In your Github Actions workflow, add the following YAML code to utilize the action:
- name: OpenAI
uses: Just-Moh-it/openai@v0.0.1
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
openai-mode: "completion"
openai-params: '{"prompt":"Repeat after me, Hello World: }}", "model": "text-davinci-003"}'
id: openai
The action requires the following inputs:
openai-api-key
: Your OpenAI API key. This should be stored as a secret in your GitHub repository. [Required: Yes]openai-mode
: The mode of the OpenAI API to use. Can becompletion
orchat
. [Required: Yes]openai-params
: A JSON string with parameters to send to the OpenAI API [Required: Yes]. Check out the params here:completion
mode: OpenAI API documentation for more information.chat
mode: OpenAI API documentation for more information.
The output of the action is a response generated by OpenAI API. You can access the response by logging the output of the action.
${{ steps.openai.outputs.completion }}
- Create a new Github repository or navigate to an existing one.
- Go to the "Actions" tab and click on "Set up a workflow yourself".
- Copy and paste the code below into the workflow file.
name: Test output of OpenAI on Push
on:
push:
branches:
- main
jobs:
openai-chat:
name: OpenAI Chat Completion
runs-on: ubuntu-latest
environment: Production
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 16
- name: OpenAI
uses: Just-Moh-it/openai@v0.0.1
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
openai-mode: "completion"
openai-params: '{"prompt":"Repeat after me, Hello World: }}", "model": "text-davinci-003"}'
id: openai
- name: Print
run: |
echo "${{ steps.openai.outputs.completion }}"
- Go to the "Settings" tab and click on "Secrets".
- Add a new secret named
OPENAI_API_KEY
with your OpenAI API key. - Use the following code to access the response generated by OpenAI API.
- Commit the changes to your repository.
The action is limited by the usage limits of your OpenAI API key.
If you have any questions or need help with this Github Action, please open an issue/discussion in the repository.
If you find any bugs or have suggestions for improvements, feel free to open an issue or create a pull request.
The project is a fork of riccardolinares/openai-commit. We thank the author for their work.