瀏覽代碼

Fix crash if missing instructions directory (#812)

Randell Miller 2 年之前
父節點
當前提交
641646a801
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      server.py

+ 4 - 1
server.py

@@ -55,7 +55,10 @@ def get_available_characters():
     return ['None'] + sorted(set((k.stem for k in paths if k.stem != "instruction-following")), key=str.lower)
 
 def get_available_instruction_templates():
-    paths = (x for x in Path('characters/instruction-following').iterdir() if x.suffix in ('.json', '.yaml', '.yml'))
+    path = "characters/instruction-following"
+    paths = []
+    if os.path.exists(path):
+        paths = (x for x in Path(path).iterdir() if x.suffix in ('.json', '.yaml', '.yml'))
     return ['None'] + sorted(set((k.stem for k in paths)), key=str.lower)
 
 def get_available_extensions():