Your ROOT_URL in app.ini is https://git.cloudchain.link/ but you are visiting https://dash.bss.nz/open-source-mirrors/GPT3Discord/commit/99e1e3b11d8b38eaf243e13e4148bc1867b9150c You should set ROOT_URL correctly, otherwise the web may not work correctly.

Format Python code with psf/black push

github-actions 2 years ago
parent 4b191ac9d8
commit 99e1e3b11d

@ -71,7 +71,9 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"):
self.pinecone_service = pinecone_service
try:
conversation_file_path = EnvService.find_shared_file("conversation_starter_pretext.txt")
conversation_file_path = EnvService.find_shared_file(
"conversation_starter_pretext.txt"
)
# Attempt to read a conversation starter text string from the file.
with conversation_file_path.open("r") as f:
self.CONVERSATION_STARTER_TEXT = f.read()
@ -80,7 +82,9 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"):
)
assert self.CONVERSATION_STARTER_TEXT is not None
conversation_file_path_minimal = EnvService.find_shared_file("conversation_starter_pretext_minimal.txt")
conversation_file_path_minimal = EnvService.find_shared_file(
"conversation_starter_pretext_minimal.txt"
)
with conversation_file_path_minimal.open("r") as f:
self.CONVERSATION_STARTER_TEXT_MINIMAL = f.read()
print(
@ -1134,7 +1138,9 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"):
): # only load in files if it's included in the command, if not pass on as normal
if opener_file.endswith(".txt"):
# Load the file and read it into opener
opener_file = EnvService.find_shared_file(f"openers{separator}{opener_file}")
opener_file = EnvService.find_shared_file(
f"openers{separator}{opener_file}"
)
opener_file = await self.load_file(opener_file, ctx)
if (
not opener

@ -34,7 +34,9 @@ class ImgPromptOptimizer(discord.Cog, name="ImgPromptOptimizer"):
self.deletion_queue = deletion_queue
try:
image_pretext_path = EnvService.find_shared_file("image_optimizer_pretext.txt")
image_pretext_path = EnvService.find_shared_file(
"image_optimizer_pretext.txt"
)
# Try to read the image optimizer pretext from
# the file system
with image_pretext_path.open("r") as file:

@ -7,12 +7,13 @@ from dotenv import load_dotenv
def app_root_path():
app_path = Path(sys.argv[0]).resolve()
try:
if app_path.parent.name == "bin": # Installed in unixy hierachy
if app_path.parent.name == "bin": # Installed in unixy hierachy
return app_path.parents[1]
except IndexError:
pass
return app_path.parent
# None will let direnv do its' thing
env_paths = [Path(".env"), app_root_path() / "etc/environment", None]
@ -27,7 +28,7 @@ class EnvService:
self.env = {}
@staticmethod
def environment_path_with_fallback(env_name, relative_fallback = None):
def environment_path_with_fallback(env_name, relative_fallback=None):
dir = os.getenv(env_name)
if dir != None:
return Path(dir).resolve()
@ -42,11 +43,17 @@ class EnvService:
@staticmethod
def find_shared_file(file_name):
share_file_paths = []
share_dir = os.getenv("SHARE_DIR")
share_dir = os.getenv("SHARE_DIR")
if share_dir != None:
share_file_paths.append(share_dir)
share_file_paths.extend([app_root_path() / "share" / file_name, app_root_path() / file_name, Path(file_name)])
share_file_paths.append(share_dir)
share_file_paths.extend(
[
app_root_path() / "share" / file_name,
app_root_path() / file_name,
Path(file_name),
]
)
for share_file_path in share_file_paths:
if share_file_path.exists():
return share_file_path.resolve()

Loading…
Cancel
Save