diff --git a/README.md b/README.md index 7167546..9420294 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ from web_search import WebSearch, WebSearchConfig, GoogleSearchConfig config = WebSearchConfig( sources=["google", "wikipedia"], google_config=GoogleSearchConfig( - api_key="your_api_key", + api_key="your_google_api_key", cse_id="your_cse_id" ) ) diff --git a/src/web_search/config.py b/src/web_search/config.py index d48f2dd..5bcd707 100644 --- a/src/web_search/config.py +++ b/src/web_search/config.py @@ -1,4 +1,5 @@ from dataclasses import dataclass, field +import os from typing import Literal SearchSources = Literal["google", "wikipedia", "arxiv"] @@ -6,8 +7,8 @@ @dataclass class GoogleSearchConfig: - api_key: str - cse_id: str + api_key: str = os.environ["GOOGLE_API_KEY"] + cse_id: str = os.environ["CSE_ID"] max_results: int = 3 app_domain: str | None = None @@ -33,4 +34,4 @@ class SearchResult: preview: str def __str__(self): - return f"Title: {self.title}\nPreview: {self.preview}" \ No newline at end of file + return f"Title: {self.title}\nPreview: {self.preview}"