Accept any search reader as a starter search provider

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Fable 5.1 committed 2026-09-30 15:44:32 +02:00
1 parent d100ab21ef
commit 800c0c428e
1 file changed
+21 -3
+21 -3
View File
@@ -16,8 +16,9 @@ the starter agents; `config.example.yaml` documents every key.
from __future__ import annotations
import os
import sys
from pathlib import Path
from typing import Any, Literal
from typing import Any
import yaml
from pydantic import Field, ValidationError, field_validator, model_validator
@@ -165,12 +166,29 @@ class SearchSeed(Section):
"""A saved search as `config.yaml` lists it: one `search` subscription,
imported once like the agents. `params` are the provider's own, see
plugins/search.py: `q`, `area` and `pages` for jobindex; `q`, `country`,
`where` and `pages` for adzuna."""
`where` and `pages` for adzuna; `q` and `region` for platsbanken. The provider is any reader of
`scope="search"`, so a new one needs no edit here."""
name: str
provider: Literal["jobindex", "adzuna"]
provider: str
params: dict[str, Any] = Field(default_factory=dict)
@field_validator("provider")
@classmethod
def _a_search_provider(cls, provider: str) -> str:
# `plugins` is a top-level folder beside `app` and is not on the path
# when this module is imported first, so it is reached the way
# `app.models` reaches it (`_declared_posted`), and only when a seed
# is validated.
root = str(Path(__file__).resolve().parents[1])
if root not in sys.path:
sys.path.insert(0, root)
from plugins.readers import PROVIDERS
if provider not in PROVIDERS:
raise ValueError(f"provider is one of {', '.join(PROVIDERS)}, not {provider!r}")
return provider
class Config(Section):
"""The whole file."""