fix: resolve prompts dir in Docker and script, try multiple locations
Build and Deploy / build-and-deploy (push) Successful in 1m34s
Build and Deploy / build-and-deploy (push) Successful in 1m34s
This commit is contained in:
@@ -19,6 +19,7 @@ RUN mkdir -p /build && date -u '+%Y-%m-%d %H:%M UTC' > /build/build-time
|
||||
ADD roux-server /usr/local/bin/roux-server
|
||||
ADD scripts/scrape-recipe /usr/local/bin/scrape-recipe
|
||||
ADD scripts/convert-to-cooklang /usr/local/bin/convert-to-cooklang
|
||||
ADD prompts /usr/local/share/roux/prompts/
|
||||
|
||||
RUN chmod +x /usr/local/bin/roux-server /usr/local/bin/scrape-recipe /usr/local/bin/convert-to-cooklang
|
||||
ENV PATH="/opt/roux-venv/bin:${PATH}"
|
||||
|
||||
@@ -42,11 +42,30 @@ def load_config(path: str) -> dict:
|
||||
def load_prompts() -> tuple[str, str, str]:
|
||||
"""Load system prompt, converter instructions, and user template.
|
||||
|
||||
Resolved relative to the script's parent directory (project root).
|
||||
Tries locations in order:
|
||||
1. ../prompts/ relative to the script (development from project root)
|
||||
2. /usr/local/share/roux/prompts/ (production Docker deployment)
|
||||
"""
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
project_root = os.path.dirname(script_dir) # scripts/ -> project root
|
||||
prompts_dir = os.path.join(project_root, "prompts")
|
||||
candidates = [
|
||||
os.path.join(script_dir, "..", "prompts"),
|
||||
"/usr/local/share/roux/prompts",
|
||||
]
|
||||
|
||||
prompts_dir = None
|
||||
for candidate in candidates:
|
||||
candidate = os.path.abspath(candidate)
|
||||
if os.path.isdir(candidate):
|
||||
prompts_dir = candidate
|
||||
break
|
||||
|
||||
if prompts_dir is None:
|
||||
print(
|
||||
"Error: prompts directory not found. "
|
||||
"Searched: " + ", ".join(candidates),
|
||||
file=sys.stderr,
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
def read(name: str) -> str:
|
||||
with open(os.path.join(prompts_dir, name)) as f:
|
||||
|
||||
Reference in New Issue
Block a user