https://github.com/karstenj/openai-examples
OpenAI examples
https://github.com/karstenj/openai-examples
html openai python uml
Last synced: 3 months ago
JSON representation
OpenAI examples
- Host: GitHub
- URL: https://github.com/karstenj/openai-examples
- Owner: karstenj
- Created: 2022-12-08T08:04:35.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-09T13:40:50.000Z (over 3 years ago)
- Last Synced: 2025-12-30T12:36:46.843Z (7 months ago)
- Topics: html, openai, python, uml
- Language: Python
- Homepage:
- Size: 33.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OpenAI Examples
A collection of [OpenAI](https://openai.com/) examples using the Python API and the model on the web.
## Quickstart
### Required Packages
* [aocd](https://github.com/wimglenn/advent-of-code-data)
* `pip install aocd`
* [openai](https://github.com/openai/openai-python)
* `pip install openai`
### Environment Variables
* AOC_SESSION - Session ID taken from browser cookie information
* OPENAI_API_KEY - Create an API key in your OpenAI account and enter it's value in this variable
## Examples
### Advent of Code
Based on @ostwilkens AoC solution https://github.com/ostwilkens/aoc2022.
Generated solutions for Advent of Code 2022:
* [day1/part1](aoc/2022-1-1.py)
* [day1/part2](aoc/2022-1-2.py)
* [day3/part1](aoc/2022-3-1.py)
* [day3/part2](aoc/2022-3-2.py)
* [day4/part1](aoc/2022-4-1.py)
* [day4/part2](aoc/2022-4-2.py)
### Cyberdojo
In this example an algorithmic problem description taken from [cyber-dojo.org](https://cyber-dojo.org) is passed to the OpenAI model text-davinci-003.
The following files have to be created per algorithmic problem:
* `_desc.txt` - problem description
* `_func.txt` - function prototype
* `_input_.txt` - input data for testing
Generated solutions:
* Print Diamond [print_diamond.py](cyberdojo/print_diamond.py) [print_diamond_desc.txt](cyberdojo/print_diamond_desc.txt)
* Anagrams [anagrams.py](cyberdojo/anagrams.py) [anagrams_desc.txt](cyberdojo/anagrams_desc.txt)
### UML Diagram
#### Description
The following description is passed to the model [text-davinci-003](https://beta.openai.com/playground?model=text-davinci-003)
```
Draw an UML model in PlantUML syntax for the following use case.
A library offers a lot of books. Books can be borrowed by users.
Borrowed books are assigned to an user.
A book has a shelf life.
```
#### Solution
[Book Library PlantUML Code](uml/BookLibrary.puml)

### HTML Page
#### Description
The following description is passed to the model [text-davinci-003](https://beta.openai.com/playground?model=text-davinci-003)
```
Snow fall on a html page
1. Create a html page with a black background color
2. Create a canvas in a html document which acts as background
3. Generate an animation of snow fall
```
#### Solution
[Snow Fall HTML Page](html/SnowFall.html "Snow Fall HTML Page")
## Special thanks to
* The OpenAI team
* Eric Wastl for creating https://adventofcode.com/
* wimglenn and contributors of https://github.com/wimglenn/advent-of-code-data
* ostwilkens sharing his OpenAI AoC solution https://github.com/ostwilkens/aoc2022