Skip to content

Commit 45dd4b6

Browse files
author
Vitamin Arrr
committed
pr comments and ensure proper error if server helper is offline
1 parent 8b7d119 commit 45dd4b6

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

gpt.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,13 @@ end
390390

391391
-- Sends json request to the remote service helper.
392392
local function send(request)
393+
if not pcall(function() client = make_client() end) then
394+
gui_text = 'Helper server is not running. cd into dfhack/scripts and run `python srv/gptserver.py` to start it. Press escape twice to close the current views, run gptserver.py, then reopen this window to generate the text.'
395+
last_knowledge_description = nil
396+
return
397+
end
398+
393399
set_current_status(Status.waiting)
394-
client = make_client()
395400
start_time = os.time()
396401
debug_log('Sending request... \n')
397402
client:send(request)
@@ -550,6 +555,3 @@ end
550555

551556
debug_log('Loaded GPT.')
552557
debug_log('valid content types: ' .. valid_content_type_list)
553-
554-
-- TODO: make into a test
555-
-- debug_log(sanitize_response('"In my pursuit of mastery as a brewer, I stumbled upon an ancient tome hidden amidst a mountain of forgotten manuscripts in the vast library of Keyspirals. Its brittle pages whispered secrets lost to time, revealing a long-forgotten recipe for a peculiar beverage known as \'Dwarven Dream Draught.\' Intrigued by its mystical allure, I dedicated countless hours to deciphering its cryptic instructions. The concoction required rare ingredients, painstakingly procured from the most elusive corners of the world – the crystallized tears of a mountain nymph, the petrified scales of a mythical fire-breathing dragon, and a single drop of moonlight captured on the night of a lunar eclipse. As I blended these exotic components with precision, a magical transformation took place. The resulting elixir possessed an otherworldly glow and an enchanting taste that transcended mortal expectations. This brew became my legacy, forever whispering of the boundless creativity and unwavering dedication of the dwarven race."'))

srv/gptserver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sys
66

77
# Read API key from file
8-
with open("../../../oaak.txt", "r") as file:
8+
with open("../../../dfhack-config/oaak.txt", "r") as file:
99
api_key = file.read().strip()
1010

1111
print("Proceeding with API key froam oaak.txt.")

0 commit comments

Comments
 (0)