This is just a personal script for how I use the openai-ruby
gem to interact with OpenAI's API, building and sending a prompt to the o1-preview
model.
- Install or update
rbenv
(andruby-build
to get access to recent releases of python).brew update && brew install ruby-build rbenv brew update && brew upgrade ruby-build rbenv
- Install ruby.
rbenv install $(cat ./.ruby-version)
- Install ruby gems.
bundle
This application requires an OpenAI API key. You can set it as an OPENAI_ACCESS_TOKEN
environment variable in your shell or in an .envrc
file. Below are steps for how to use direnv
to manage environment variables, but you can also simply set the environment variable in your shell.
- Install
direnv
and configure your shell to enable automatic environment variable loading.brew install direnv
- Update your dotfiles to use the direnv hook.
# in e.g. ~/.bash_profile if which direnv > /dev/null; then eval "$(direnv hook bash)" fi
- If you use zsh instead of bash, replace
direnv hook bash
withdirenv hook zsh
. See the hooks documentation page in the direnv GitHub repository for more details.
- If you use zsh instead of bash, replace
- Copy
.envrc.example
to.envrc
.cp .envrc.example .envrc
- Fill out
.envrc
. - Source the environment variables defined in
.envrc
.direnv allow
Write a prompt in a file in the prompts/
directory, e.g. prompts/o1-preview-000001
. Consider using this script to merge many files into one in a way that's useful when prompting.
There's an o1_preview_client.rb
file. Use it to execute the prompt.
bundle exec ruby o1_preview_client.rb execute prompts/o1-preview-000001
The result will be in the log/
directory. There's no support for follow up prompts, so if there's anything from the result that you want to use in a follow up prompt, you'll have to copy it manually.
If you'd like to contribute to the project, please feel free to submit a pull request or open an issue to discuss your ideas.
This project is licensed under the MIT License. See the LICENSE file for more information.