f8a23855d2
- Admin-configurable AI prompt/quick questions from system_configs DB - GET /api/v1/ai/quick-questions endpoint for fetching quick questions - Local FAQ matching for instant responses (avoid AI calls for common Qs) - AI action extraction: "add customer" intent detected, structured data returned - Frontend action confirmation card with editable fields, calls customer API on confirm - NVIDIA provider (stepfun-ai/step-3.5-flash) for faster chat vs deepseek-v4-flash - Fixed httpx client timeout preventing backend hangs - Added log_usage calls for auth events (register/login/guest/wechat) - Admin tabs (users/stats/logs/config) fully functional with real backend - AiAssistant component added to all tabbar pages
50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
from abc import ABC, abstractmethod
|
|
from typing import Dict, Any, Optional
|
|
|
|
|
|
class AIProvider(ABC):
|
|
@abstractmethod
|
|
async def translate(
|
|
self, text: str, source_lang: Optional[str], target_lang: str,
|
|
context: Optional[str] = None,
|
|
) -> Dict[str, Any]:
|
|
pass
|
|
|
|
@abstractmethod
|
|
async def reply(
|
|
self, inquiry: str, context: Optional[Dict[str, Any]] = None,
|
|
tone: str = "professional", preference_context: Optional[str] = None,
|
|
) -> Dict[str, Any]:
|
|
pass
|
|
|
|
@abstractmethod
|
|
async def generate_marketing(
|
|
self, product_info: Dict[str, Any], target: str,
|
|
style: str = "professional", language: str = "en",
|
|
preference_context: Optional[str] = None,
|
|
) -> Dict[str, Any]:
|
|
pass
|
|
|
|
@abstractmethod
|
|
async def extract_info(
|
|
self, text: str, schema: Dict[str, Any],
|
|
) -> Dict[str, Any]:
|
|
pass
|
|
|
|
async def chat(self, message: str, history: list = None, system_prompt: str = None) -> Dict[str, Any]:
|
|
raise NotImplementedError
|
|
|
|
@property
|
|
@abstractmethod
|
|
def name(self) -> str:
|
|
pass
|
|
|
|
@property
|
|
@abstractmethod
|
|
def cost_per_1k_tokens(self) -> float:
|
|
pass
|
|
|
|
@property
|
|
def supports_streaming(self) -> bool:
|
|
return False
|