Merge pull request #356 from dinakars777/fix/allow-threads-pinterest-search
fix: honor explicit optional source requests
This commit is contained in:
@@ -79,6 +79,8 @@ MOCK_AVAILABLE_SOURCES = [
|
|||||||
"xiaohongshu",
|
"xiaohongshu",
|
||||||
"github",
|
"github",
|
||||||
"perplexity",
|
"perplexity",
|
||||||
|
"threads",
|
||||||
|
"pinterest",
|
||||||
"xquik",
|
"xquik",
|
||||||
"digg",
|
"digg",
|
||||||
]
|
]
|
||||||
@@ -118,7 +120,9 @@ def available_sources(config: dict[str, Any], requested_sources: list[str] | Non
|
|||||||
available.append("grounding")
|
available.append("grounding")
|
||||||
# Perplexity Sonar: opt-in additive source via INCLUDE_SOURCES=perplexity
|
# Perplexity Sonar: opt-in additive source via INCLUDE_SOURCES=perplexity
|
||||||
include_sources = (config.get("INCLUDE_SOURCES") or "").lower().split(",")
|
include_sources = (config.get("INCLUDE_SOURCES") or "").lower().split(",")
|
||||||
if config.get("OPENROUTER_API_KEY") and "perplexity" in include_sources:
|
if config.get("OPENROUTER_API_KEY") and (
|
||||||
|
"perplexity" in include_sources or (requested_sources and "perplexity" in requested_sources)
|
||||||
|
):
|
||||||
available.append("perplexity")
|
available.append("perplexity")
|
||||||
if requested_sources and "xiaohongshu" in requested_sources and env.is_xiaohongshu_available(config):
|
if requested_sources and "xiaohongshu" in requested_sources and env.is_xiaohongshu_available(config):
|
||||||
available.append("xiaohongshu")
|
available.append("xiaohongshu")
|
||||||
|
|||||||
@@ -72,6 +72,26 @@ class CliV3Tests(unittest.TestCase):
|
|||||||
cli.parse_search_flag("web, reddit, hn, web"),
|
cli.parse_search_flag("web, reddit, hn, web"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_parse_search_flag_accepts_optional_social_sources(self):
|
||||||
|
self.assertEqual(
|
||||||
|
["threads", "pinterest"],
|
||||||
|
cli.parse_search_flag("threads, pinterest"),
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_explicit_threads_search_uses_scrapecreators_key_without_include_sources(self):
|
||||||
|
available = cli.pipeline.available_sources(
|
||||||
|
{"SCRAPECREATORS_API_KEY": "test-key", "INCLUDE_SOURCES": ""},
|
||||||
|
requested_sources=["threads"],
|
||||||
|
)
|
||||||
|
self.assertIn("threads", available)
|
||||||
|
|
||||||
|
def test_explicit_perplexity_search_uses_openrouter_key_without_include_sources(self):
|
||||||
|
available = cli.pipeline.available_sources(
|
||||||
|
{"OPENROUTER_API_KEY": "test-key", "INCLUDE_SOURCES": ""},
|
||||||
|
requested_sources=["perplexity"],
|
||||||
|
)
|
||||||
|
self.assertIn("perplexity", available)
|
||||||
|
|
||||||
def test_parse_search_flag_rejects_invalid_or_empty_inputs(self):
|
def test_parse_search_flag_rejects_invalid_or_empty_inputs(self):
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
cli.parse_search_flag("unknown")
|
cli.parse_search_flag("unknown")
|
||||||
|
|||||||
Reference in New Issue
Block a user