-
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added branching to logmanager (#33)
* feat: added branching to logmanager, to allow tree-structured conversations * feat: more progress on branching, added support for switching branches in web UI * fix: added dirs.py to better handle directories and paths, misc fixes * build: fixed Makefile EXCLUDES for SRCFILES * fix: fixed bug in commands.py * feat: added ability to send messages to non-main branch in web UI
- Loading branch information
Showing
14 changed files
with
415 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
from platformdirs import user_config_dir, user_data_dir | ||
|
||
|
||
def get_config_dir() -> Path: | ||
return Path(user_config_dir("gptme")) | ||
|
||
|
||
def get_readline_history_file() -> Path: | ||
# TODO: move to data dir | ||
return get_config_dir() / "history" | ||
|
||
|
||
def get_data_dir() -> Path: | ||
# used in testing, so must take precedence | ||
if "XDG_DATA_HOME" in os.environ: | ||
return Path(os.environ["XDG_DATA_HOME"]) / "gptme" | ||
|
||
# just a workaround for me personally | ||
old = Path("~/.local/share/gptme").expanduser() | ||
if old.exists(): | ||
return old | ||
|
||
return Path(user_data_dir("gptme")) | ||
|
||
|
||
def get_logs_dir() -> Path: | ||
"""Get the path for **conversation logs** (not to be confused with the logger file)""" | ||
path = get_data_dir() / "logs" | ||
path.mkdir(parents=True, exist_ok=True) | ||
return path | ||
|
||
|
||
def _init_paths(): | ||
# create all paths | ||
for path in [get_config_dir(), get_data_dir(), get_logs_dir()]: | ||
path.mkdir(parents=True, exist_ok=True) | ||
|
||
|
||
# run once on init | ||
_init_paths() |
Oops, something went wrong.