File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 1+ import sys
12import os
23import json
34import yaml
45
6+
7+ def resource_path (relative_path ):
8+ if hasattr (sys , '_MEIPASS' ):
9+ return os .path .join (sys ._MEIPASS , relative_path )
10+ return os .path .join (os .path .abspath ("." ), relative_path )
11+
12+
513def load_api_key ():
614 path = os .path .join (os .path .expanduser ("~/.api_keys" ), "openai.json" )
715 if not os .path .exists (path ):
@@ -11,9 +19,10 @@ def load_api_key():
1119 return data ["api_key" ]
1220
1321
14- def load_prompt_template (path : str = './prompt_template.yml' ):
15- if not os .path .exists (path ):
22+ def load_prompt_template (path : str = 'prompt_template.yml' ):
23+ full_path = resource_path (path )
24+ if not os .path .exists (full_path ):
1625 raise FileNotFoundError (f"❌ Prompt template not found: { path } " )
17- with open (path , "r" , encoding = 'utf-8' ) as f :
26+ with open (full_path , "r" , encoding = 'utf-8' ) as f :
1827 config = yaml .safe_load (f )
1928 return config ['commit_format' ], config ['commit_type' ]
You can’t perform that action at this time.
0 commit comments