feat: AI routing DB-driven, payment gateway full integration, WeChat mini-program CI/CD
- AI routing rules now stored in system_configs DB table instead of hardcoded config - Multi-model support via name|model composite key for same-provider routing - UnifiedPayService with HMAC-SHA256 gateway integration (alipay/wechat) - Admin payment panel: list, stats, search, filter, refund - WeChat mini-program CI/CD via miniprogram-ci (v1.0.9) - Translation quota extended to LLM provider tier - SearchService with DB-driven provider config (bing/google_cse/searxng) - Footer cleanup across admin/workspace/uni-app - Private key excluded from git tracking
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import json
|
||||
import logging
|
||||
from typing import Dict, Any, Optional, Union
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.ai.router import get_ai_router
|
||||
from app.services.search_web import search_companies, fetch_page_text
|
||||
@@ -29,10 +30,11 @@ ANALYZE_MATCH_PROMPT = """你是外贸客户分析专家。分析目标公司的
|
||||
|
||||
|
||||
class DiscoveryService:
|
||||
def __init__(self):
|
||||
def __init__(self, db: Optional[AsyncSession] = None):
|
||||
ai_router = get_ai_router()
|
||||
self.ai = ai_router
|
||||
self._ai_available = len(ai_router.providers) > 0
|
||||
self.db = db
|
||||
|
||||
async def search(self, product_description: str, target_market: str) -> Dict[str, Any]:
|
||||
queries = self._build_queries(product_description, target_market)
|
||||
@@ -124,6 +126,18 @@ URL: {company_url}
|
||||
return self._template_outreach(company_info, product_info)
|
||||
|
||||
async def _web_search_all(self, queries: list) -> dict:
|
||||
# Try DB-managed search providers first
|
||||
if self.db:
|
||||
try:
|
||||
from app.services.search import SearchService
|
||||
svc = SearchService(self.db)
|
||||
db_results = await svc.search(queries[0], limit=15)
|
||||
if db_results:
|
||||
return {"results": self._dedup_and_filter(db_results)[:15], "provider": "db_search"}
|
||||
except Exception as e:
|
||||
logger.warning(f"DB search failed: {e}")
|
||||
|
||||
# Fallback: hardcoded Bing + 360 scraper
|
||||
try:
|
||||
results = await search_bing_batch(queries[:3], max_per_query=4)
|
||||
if results:
|
||||
@@ -131,6 +145,7 @@ URL: {company_url}
|
||||
except Exception as e:
|
||||
logger.warning(f"Bing batch search failed: {e}")
|
||||
|
||||
# Fallback: Google CSE from env vars
|
||||
results = await search_companies(queries[0], max_results=10)
|
||||
if results:
|
||||
return {"results": results[:15], "provider": "google_cse"}
|
||||
|
||||
Reference in New Issue
Block a user