Skip to content

Search1Config

Base classes

Name Children Inherits
BaseSearchProviderConfig
searchly_config.configs
Base search provider configuration.

⋔ Inheritance diagram

graph TD
  2055181617["configs.Search1Config"]
  860522681["configs.BaseSearchProviderConfig"]
  330168112["schema.Schema"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  860522681 --> 2055181617
  330168112 --> 860522681
  3879467795 --> 330168112
  2751680898 --> 3879467795

🛈 DocStrings

Bases: BaseSearchProviderConfig

Search1API provider configuration.

Uses the Search1API for web search via Google or Bing. Supports language filtering and time ranges.

Source code in src/searchly_config/configs.py
class Search1Config(BaseSearchProviderConfig):
    """Search1API provider configuration.

    Uses the Search1API for web search via Google or Bing.
    Supports language filtering and time ranges.
    """

    type: Literal["search1"] = Field("search1", init=False)
    """Search1API provider."""

    api_key: SecretStr | None = Field(default=None, title="API Key")
    """Search1API key. Defaults to SEARCH1API_KEY env var."""

    base_url: str = Field(
        default="https://api.search1api.com",
        title="Base URL",
    )
    """Base URL for the API."""

    def is_configured(self) -> bool:
        """Check if Search1API credentials are configured."""
        return self.api_key is not None or bool(os.getenv("SEARCH1API_KEY"))

    def get_provider(self) -> AsyncSearch1API:
        """Create Search1API provider instance."""
        from searchly.providers.search1_provider.client import AsyncSearch1API

        api_key = self.api_key.get_secret_value() if self.api_key else None
        return AsyncSearch1API(api_key=api_key, base_url=self.base_url)

api_key class-attribute instance-attribute

api_key: SecretStr | None = Field(default=None, title='API Key')

Search1API key. Defaults to SEARCH1API_KEY env var.

base_url class-attribute instance-attribute

base_url: str = Field(default='https://api.search1api.com', title='Base URL')

Base URL for the API.

type class-attribute instance-attribute

type: Literal['search1'] = Field('search1', init=False)

Search1API provider.

get_provider

get_provider() -> AsyncSearch1API

Create Search1API provider instance.

Source code in src/searchly_config/configs.py
def get_provider(self) -> AsyncSearch1API:
    """Create Search1API provider instance."""
    from searchly.providers.search1_provider.client import AsyncSearch1API

    api_key = self.api_key.get_secret_value() if self.api_key else None
    return AsyncSearch1API(api_key=api_key, base_url=self.base_url)

is_configured

is_configured() -> bool

Check if Search1API credentials are configured.

Source code in src/searchly_config/configs.py
def is_configured(self) -> bool:
    """Check if Search1API credentials are configured."""
    return self.api_key is not None or bool(os.getenv("SEARCH1API_KEY"))

:fa-brands-github: Show source on GitHub