Skip to content

Commit 95526f8

Browse files
author
Vitamin Arrr
committed
add plugin that generates written content using artificial intelligence via OpenAI API
1 parent 34ae01a commit 95526f8

File tree

3 files changed

+728
-0
lines changed

3 files changed

+728
-0
lines changed

docs/gpt.rst

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
gpt
2+
=======
3+
4+
.. dfhack-tool::
5+
:summary: AI-generated written content!
6+
:tags: fort gameplay
7+
8+
Enables a UI for submitting knowledge item descriptions to OpenAI for generating
9+
poetry, star charts, and excerpts from longer works such as biographies, dictionaries,
10+
treatises on technological evolution, comparative biographies, cultural histories,
11+
autobiographies, cultural comparisons, essays, guides, manuals, and more.
12+
13+
``enable gpt``
14+
=======
15+
Enables the plugin. The overlay will be shown when a knowledge item or unit view sheet is open.
16+
17+
``disable gpt``
18+
=======
19+
Disables the plugin.
20+
21+
Setup:
22+
23+
1. Register for an OpenAI API account. It must be a paid or active trial account.
24+
2. Generate an API token for your account.
25+
3. Save your OpenAI API token to a file at the root of your DF directory, `oaak.txt`.
26+
4. Install python. We used version 3.11 installed from the Microsoft Store.
27+
5. Install python dependencies Flask and OpenAI: `pip install Flask` and `pip install OpenAI`.
28+
6. Start the local helper python app: cd into dfhack/scripts directory & run `python gptserver.py`.
29+
30+
Once the python helper is running, you may now enable and use the gpt plugin.
31+
32+
The python script defaults to using the fast, cheap, legacy model `text-davinci-003`.
33+
If you wish to use the slower, more expensive `gpt-3.5-turbo` or `gpt-4` models, you
34+
can start the script with `python gptserver.py -gpt3` or `python gptserver.py -gpt4`.
35+
Tweaking additional OpenAI API parameters will require modifying `gptserver.py` to suit
36+
your particular desires, until such time as someone may have added additional
37+
configuration options in a future update to DFHack :D
38+
39+
Note: EVERY TEXT YOU GENERATE COSTS $$ if you are on a paid account. The fee is appx. $0.005 USD
40+
at the time of this writing. YMMV!
41+
42+
Versions of python dependencies tested with:
43+
44+
Package Version
45+
------------------ ---------
46+
aiohttp 3.8.5
47+
aiosignal 1.3.1
48+
async-timeout 4.0.2
49+
attrs 23.1.0
50+
blinker 1.6.2
51+
certifi 2023.7.22
52+
charset-normalizer 3.2.0
53+
click 8.1.6
54+
colorama 0.4.6
55+
Flask 2.3.2
56+
frozenlist 1.4.0
57+
idna 3.4
58+
itsdangerous 2.1.2
59+
Jinja2 3.1.2
60+
MarkupSafe 2.1.3
61+
multidict 6.0.4
62+
openai 0.27.8
63+
requests 2.31.0
64+
tqdm 4.65.0
65+
urllib3 2.0.4
66+
Werkzeug 2.3.6
67+
yarl 1.9.2

0 commit comments

Comments
 (0)