fix(config): handle /v1 suffix in PAGEPIPER_OLLAMA_URL; add DATA_DIR mkdir guard
This commit is contained in:
parent
9797e76931
commit
abeb6089e5
2 changed files with 13 additions and 4 deletions
|
|
@ -6,6 +6,7 @@ import os
|
|||
from pathlib import Path
|
||||
|
||||
DATA_DIR = Path(os.environ.get("PAGEPIPER_DATA_DIR", "data"))
|
||||
DATA_DIR.mkdir(parents=True, exist_ok=True)
|
||||
DB_PATH = str(DATA_DIR / "pagepiper.db")
|
||||
VEC_DB_PATH = str(DATA_DIR / "pagepiper_vecs.db")
|
||||
WATCH_DIR = Path(os.environ.get("PAGEPIPER_WATCH_DIR", "books"))
|
||||
|
|
@ -16,12 +17,14 @@ def get_llm_config() -> dict | None:
|
|||
url = os.environ.get("PAGEPIPER_OLLAMA_URL", "").strip()
|
||||
if not url:
|
||||
return None
|
||||
_clean = url.rstrip("/")
|
||||
_base_url = _clean if _clean.endswith("/v1") else _clean + "/v1"
|
||||
return {
|
||||
"fallback_order": ["ollama"],
|
||||
"backends": {
|
||||
"ollama": {
|
||||
"type": "openai_compat",
|
||||
"base_url": url.rstrip("/") + "/v1",
|
||||
"base_url": _base_url,
|
||||
"model": os.environ.get("PAGEPIPER_CHAT_MODEL", "mistral:7b"),
|
||||
"embedding_model": os.environ.get(
|
||||
"PAGEPIPER_EMBED_MODEL", "nomic-embed-text"
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ import pytest
|
|||
|
||||
def test_migration_creates_documents_table(tmp_path):
|
||||
db_path = str(tmp_path / "test.db")
|
||||
schema = Path("migrations/001_initial_schema.sql").read_text()
|
||||
schema = (
|
||||
Path(__file__).parent.parent / "migrations/001_initial_schema.sql"
|
||||
).read_text()
|
||||
|
||||
conn = sqlite3.connect(db_path)
|
||||
conn.executescript(schema)
|
||||
|
|
@ -28,7 +30,9 @@ def test_migration_creates_documents_table(tmp_path):
|
|||
|
||||
def test_documents_table_has_required_columns(tmp_path):
|
||||
db_path = str(tmp_path / "test.db")
|
||||
schema = Path("migrations/001_initial_schema.sql").read_text()
|
||||
schema = (
|
||||
Path(__file__).parent.parent / "migrations/001_initial_schema.sql"
|
||||
).read_text()
|
||||
|
||||
conn = sqlite3.connect(db_path)
|
||||
conn.executescript(schema)
|
||||
|
|
@ -47,7 +51,9 @@ def test_documents_table_has_required_columns(tmp_path):
|
|||
|
||||
def test_page_chunks_foreign_key_cascades(tmp_path):
|
||||
db_path = str(tmp_path / "test.db")
|
||||
schema = Path("migrations/001_initial_schema.sql").read_text()
|
||||
schema = (
|
||||
Path(__file__).parent.parent / "migrations/001_initial_schema.sql"
|
||||
).read_text()
|
||||
|
||||
conn = sqlite3.connect(db_path)
|
||||
conn.executescript(schema)
|
||||
|
|
|
|||
Loading…
Reference in a new issue