add internal Degoog prospect search fallback
This commit is contained in:
+12
-1
@@ -100,7 +100,18 @@ class BrowserOnlyAppTests(unittest.TestCase):
|
||||
self.assertTrue(first_call.args[2]["email"])
|
||||
self.assertEqual(http_bytes.call_args.args[1], "http://gmaps:8080/api/v1/jobs/job-1/download")
|
||||
|
||||
def test_nous_provider_exposes_models_and_tests_connection(self):
|
||||
def test_degoog_search_normalises_candidates_and_keeps_provenance(self):
|
||||
class Response:
|
||||
def __enter__(self): return self
|
||||
def __exit__(self, *args): return None
|
||||
def read(self, _limit=None):
|
||||
return json.dumps({"results": [{"url": "https://www.acme.co.za/", "title": "Acme Plumbing", "content": "Acme Plumbing Cape Town"}]}).encode()
|
||||
prospect = {"name": "Acme Plumbing", "address": "Cape Town", "category": "Plumbers", "phone": ""}
|
||||
with patch.dict(os.environ, {"DEGOOG_ENABLED": "true", "DEGOOG_URL": "http://degoog:4444"}, clear=False), patch("api.browser_investigator.urllib.request.urlopen", return_value=Response()):
|
||||
results = browser_investigator._degoog_search_candidates(prospect, ['"Acme Plumbing" Cape Town'], requested=3, timeout_seconds=10)
|
||||
self.assertEqual(results[0]["source"], "degoog")
|
||||
self.assertEqual(results[0]["domain"], "acme.co.za")
|
||||
|
||||
free_models = [{"id": "meituan/longcat-2.0:free", "label": "Meituan · LongCat 2.0", "free": True}]
|
||||
with patch.object(server, "nous_models", return_value=free_models):
|
||||
status, body = self.request("GET", "/api/ai/models?provider=nous")
|
||||
|
||||
Reference in New Issue
Block a user