Hasan Iqbal
commited on
Replaced Azure Search Key by Scraper API Key
Browse files
src/openfactcheck/lib/config.py
CHANGED
@@ -83,7 +83,7 @@ class OpenFactCheckConfig:
|
|
83 |
self.filename_or_path = filename_or_path
|
84 |
|
85 |
# Define namedtuple structures
|
86 |
-
Secrets = namedtuple("Secrets", ["openai_api_key", "serper_api_key", "
|
87 |
|
88 |
# Define Attributes
|
89 |
self.config: dict = {}
|
@@ -92,7 +92,7 @@ class OpenFactCheckConfig:
|
|
92 |
self.solver_configs: dict[Any, Any] = SolversConfig(solver_config_template_files)()
|
93 |
self.solver_paths: dict[str, list[str]] = {"default": solver_templates_paths, "user_defined": []}
|
94 |
self.output_path: str = "tmp/output"
|
95 |
-
self.secrets: Secrets = Secrets(openai_api_key=None, serper_api_key=None,
|
96 |
self.verbose = "WARNING"
|
97 |
|
98 |
try:
|
@@ -171,7 +171,7 @@ class OpenFactCheckConfig:
|
|
171 |
self.secrets = Secrets(
|
172 |
openai_api_key=self.config["secrets"]["openai_api_key"],
|
173 |
serper_api_key=self.config["secrets"]["serper_api_key"],
|
174 |
-
|
175 |
)
|
176 |
else:
|
177 |
self.logger.warning(
|
@@ -183,8 +183,8 @@ class OpenFactCheckConfig:
|
|
183 |
os.environ["OPENAI_API_KEY"] = self.secrets.openai_api_key
|
184 |
if self.secrets.serper_api_key:
|
185 |
os.environ["SERPER_API_KEY"] = self.secrets.serper_api_key
|
186 |
-
if self.secrets.
|
187 |
-
os.environ["
|
188 |
|
189 |
# Initialize Verbose
|
190 |
if "verbose" in self.config:
|
@@ -233,9 +233,9 @@ class OpenFactCheckConfig:
|
|
233 |
if "SERPER_API_KEY" not in os.environ:
|
234 |
self.logger.warning("SERPER_API_KEY environment variable not found.")
|
235 |
raise ConfigValidationError("SERPER_API_KEY environment variable not found.")
|
236 |
-
if "
|
237 |
-
self.logger.warning("
|
238 |
-
raise ConfigValidationError("
|
239 |
|
240 |
def solver_configuration(self, solver: str | None = None) -> dict:
|
241 |
"""
|
|
|
83 |
self.filename_or_path = filename_or_path
|
84 |
|
85 |
# Define namedtuple structures
|
86 |
+
Secrets = namedtuple("Secrets", ["openai_api_key", "serper_api_key", "scraper_api_key"])
|
87 |
|
88 |
# Define Attributes
|
89 |
self.config: dict = {}
|
|
|
92 |
self.solver_configs: dict[Any, Any] = SolversConfig(solver_config_template_files)()
|
93 |
self.solver_paths: dict[str, list[str]] = {"default": solver_templates_paths, "user_defined": []}
|
94 |
self.output_path: str = "tmp/output"
|
95 |
+
self.secrets: Secrets = Secrets(openai_api_key=None, serper_api_key=None, scraper_api_key=None)
|
96 |
self.verbose = "WARNING"
|
97 |
|
98 |
try:
|
|
|
171 |
self.secrets = Secrets(
|
172 |
openai_api_key=self.config["secrets"]["openai_api_key"],
|
173 |
serper_api_key=self.config["secrets"]["serper_api_key"],
|
174 |
+
scraper_api_key=self.config["secrets"]["scraper_api_key"],
|
175 |
)
|
176 |
else:
|
177 |
self.logger.warning(
|
|
|
183 |
os.environ["OPENAI_API_KEY"] = self.secrets.openai_api_key
|
184 |
if self.secrets.serper_api_key:
|
185 |
os.environ["SERPER_API_KEY"] = self.secrets.serper_api_key
|
186 |
+
if self.secrets.scraper_api_key:
|
187 |
+
os.environ["scraper_api_key"] = self.secrets.scraper_api_key
|
188 |
|
189 |
# Initialize Verbose
|
190 |
if "verbose" in self.config:
|
|
|
233 |
if "SERPER_API_KEY" not in os.environ:
|
234 |
self.logger.warning("SERPER_API_KEY environment variable not found.")
|
235 |
raise ConfigValidationError("SERPER_API_KEY environment variable not found.")
|
236 |
+
if "SCRAPER_API_KEY" not in os.environ:
|
237 |
+
self.logger.warning("SCRAPER_API_KEY environment variable not found.")
|
238 |
+
raise ConfigValidationError("SCRAPER_API_KEY environment variable not found.")
|
239 |
|
240 |
def solver_configuration(self, solver: str | None = None) -> dict:
|
241 |
"""
|