Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix characters and save instruction-templates and logs in .textgen #71

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 28 additions & 37 deletions projects/textgen/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,11 @@ let
mv ./prompts ./_prompts
mv ./characters ./_characters
mv ./presets ./_presets
mv ./instruction-templates ./_instruction-templates
cd -

substituteInPlace ./src/modules/presets.py \
--replace "Path('presets" "Path('$out/presets" \
--replace "Path('prompts" "Path('$out/prompts" \
--replace "Path(f'prompts" "Path(f'$out/prompts" \
--replace "Path('extensions" "Path('$out/extensions" \
--replace "Path(f'presets" "Path(f'$out/presets" \
--replace "Path('softprompts" "Path('$out/softprompts" \
--replace "Path(f'softprompts" "Path(f'$out/softprompts" \
--replace "Path('characters" "Path('$out/characters" \
--replace "Path('cache" "Path('$out/cache"
--replace "Path(f'presets" "Path(f'$out/presets"
substituteInPlace ./src/download-model.py \
--replace "=args.output" "='$out/models/'" \
--replace "base_folder=None" "base_folder='$out/models/'"
Expand All @@ -37,43 +31,37 @@ let
substituteInPlace ./src/modules/utils.py \
--replace "Path('css" "Path('$out/css" \
--replace "Path('characters" "Path('$out/characters" \
--replace "characters/" "$out/characters/"
--replace "rel_path = abs_path.relative_to(root_folder)" "" \
--replace "rel_path.parts[0] == '..'" "False"
substituteInPlace ./src/modules/chat.py \
--replace "folder = 'characters'" "folder = '$out/characters'" \
--replace "Path('characters" "Path('$out/characters" \
--replace "characters/" "$out/characters/"
substituteInPlace ./src/server.py \
--replace "Path('presets" "Path('$out/presets" \
--replace "Path('prompts" "Path('$out/prompts" \
--replace "Path(f'prompts" "Path(f'$out/prompts" \
--replace "Path('extensions" "Path('$out/extensions" \
--replace "Path(f'presets" "Path(f'$out/presets" \
--replace "Path('softprompts" "Path('$out/softprompts" \
--replace "Path(f'softprompts" "Path(f'$out/softprompts" \
--replace "Path('characters" "Path('$out/characters" \
--replace "Path('cache" "Path('$out/cache"
substituteInPlace ./src/download-model.py \
--replace "=args.output" "='$out/models/'" \
--replace "base_folder=None" "base_folder='$out/models/'"
substituteInPlace ./src/modules/html_generator.py \
--replace "../css" "$out/css" \
--replace 'Path(__file__).resolve().parent / ' "" \
--replace "Path(f'css" "Path(f'$out/css"
substituteInPlace ./src/modules/utils.py \
--replace "Path('css" "Path('$out/css" \
--replace "Path('characters" "Path('$out/characters" \
--replace "characters/" "$out/characters/"
substituteInPlace ./src/modules/chat.py \
--replace "folder = 'characters'" "folder = '$out/characters'" \
--replace "Path('characters" "Path('$out/characters" \
--replace "characters/" "$out/characters/"

substituteInPlace \
./src/modules/prompts.py \
./src/modules/ui_chat.py \
./src/modules/utils.py \
./src/modules/chat.py \
--replace "instruction-templates" "$out/instruction-templates"

substituteInPlace \
./src/modules/evaluate.py \
./src/modules/training.py \
./src/modules/chat.py \
--replace "Path('logs" "Path('$out/logs"
substituteInPlace \
./src/modules/chat.py \
--replace "Path(f'logs" "Path(f'$out/logs"

mv ./src $out
ln -s ${tmpDir}/models/ $out/models
ln -s ${tmpDir}/loras/ $out/loras
ln -s ${tmpDir}/cache/ $out/cache
ln -s ${tmpDir}/prompts/ $out/prompts
ln -s ${tmpDir}/characters/ $out/characters
ln -s ${tmpDir}/presets/ $out/presets
ln -s ${tmpDir}/instruction-templates $out/instruction-templates
ln -s ${tmpDir}/logs $out/logs
'';
textgenPython = python3Packages.python.withPackages (_: with python3Packages; [
accelerate
Expand Down Expand Up @@ -121,16 +109,19 @@ in
fi
rm -rf ${tmpDir}
mkdir -p ${tmpDir}
mkdir -p ${stateDir}/models ${stateDir}/cache ${stateDir}/loras ${stateDir}/prompts ${stateDir}/characters ${stateDir}/presets
mkdir -p ${stateDir}/{models,cache,loras,prompts,characters,presets,instruction-templates,logs}
cp -r --no-preserve=mode ${patchedSrc}/_prompts/* ${stateDir}/prompts/
cp -r --no-preserve=mode ${patchedSrc}/_characters/* ${stateDir}/characters/
cp -r --no-preserve=mode ${patchedSrc}/_presets/* ${stateDir}/presets/
cp -r --no-preserve=mode ${patchedSrc}/_instruction-templates/* ${stateDir}/instruction-templates/
ln -s ${stateDir}/models/ ${tmpDir}/models
ln -s ${stateDir}/loras/ ${tmpDir}/loras
ln -s ${stateDir}/cache/ ${tmpDir}/cache
ln -s ${stateDir}/prompts/ ${tmpDir}/prompts
ln -s ${stateDir}/characters/ ${tmpDir}/characters
ln -s ${stateDir}/presets/ ${tmpDir}/presets
ln -s ${stateDir}/instruction-templates ${tmpDir}/instruction-templates
ln -s ${stateDir}/logs ${tmpDir}/logs
${lib.optionalString (python3Packages.torch.rocmSupport or false) rocmInit}
export LD_LIBRARY_PATH=/run/opengl-driver/lib:${cudaPackages.cudatoolkit}/lib
${textgenPython}/bin/python ${patchedSrc}/server.py $@ \
Expand Down