恢复GE版本为0.18,生成SNIPPET后自动生成rag_text流程
This commit is contained in:
@ -24,7 +24,6 @@ from app.services import LLMGateway
|
||||
from app.settings import DEFAULT_IMPORT_MODEL
|
||||
from app.services.import_analysis import (
|
||||
IMPORT_GATEWAY_BASE_URL,
|
||||
build_import_gateway_headers,
|
||||
resolve_provider_from_model,
|
||||
)
|
||||
from app.utils.llm_usage import extract_usage as extract_llm_usage
|
||||
@ -533,7 +532,6 @@ async def _call_chat_completions(
|
||||
temperature: float = 0.2,
|
||||
timeout_seconds: Optional[float] = None,
|
||||
) -> Any:
|
||||
# Normalize model spec to provider+model and issue the unified chat call.
|
||||
provider, model_name = resolve_provider_from_model(model_spec)
|
||||
payload = {
|
||||
"provider": provider.value,
|
||||
@ -547,17 +545,16 @@ async def _call_chat_completions(
|
||||
payload_size_bytes = len(json.dumps(payload, ensure_ascii=False).encode("utf-8"))
|
||||
|
||||
url = f"{IMPORT_GATEWAY_BASE_URL.rstrip('/')}/v1/chat/completions"
|
||||
headers = build_import_gateway_headers()
|
||||
try:
|
||||
# log the request whole info
|
||||
logger.info(
|
||||
"Calling chat completions API %s with model=%s payload_size=%sB",
|
||||
"Calling chat completions API %s with model %s and size %s and payload %s",
|
||||
url,
|
||||
model_name,
|
||||
payload_size_bytes,
|
||||
payload,
|
||||
)
|
||||
response = await client.post(
|
||||
url, json=payload, timeout=timeout_seconds, headers=headers
|
||||
)
|
||||
response = await client.post(url, json=payload, timeout=timeout_seconds)
|
||||
|
||||
response.raise_for_status()
|
||||
except httpx.HTTPError as exc:
|
||||
@ -706,7 +703,6 @@ async def _run_action_with_callback(
|
||||
input_payload: Any = None,
|
||||
model_spec: Optional[str] = None,
|
||||
) -> Any:
|
||||
# Execute a pipeline action and always emit a callback capturing success/failure.
|
||||
if input_payload is not None:
|
||||
logger.info(
|
||||
"Pipeline action %s input: %s",
|
||||
@ -789,6 +785,8 @@ async def process_table_profiling_job(
|
||||
"table_schema_version_id": request.table_schema_version_id,
|
||||
"llm_model": request.llm_model,
|
||||
"llm_timeout_seconds": timeout_seconds,
|
||||
"workspace_id": request.workspace_id,
|
||||
"rag_item_type": request.rag_item_type,
|
||||
}
|
||||
|
||||
logging_request_payload = _profiling_request_for_log(request)
|
||||
|
||||
@ -459,6 +459,18 @@ def _stable_rag_item_id(table_id: int, version_ts: int, snippet_id: str) -> int:
|
||||
return int(digest[:16], 16) % 9_000_000_000_000_000_000
|
||||
|
||||
|
||||
def _to_serializable(value: Any) -> Any:
|
||||
if value is None or isinstance(value, (str, int, float, bool)):
|
||||
return value
|
||||
if isinstance(value, datetime):
|
||||
return value.isoformat()
|
||||
if isinstance(value, dict):
|
||||
return {k: _to_serializable(v) for k, v in value.items()}
|
||||
if isinstance(value, list):
|
||||
return [_to_serializable(v) for v in value]
|
||||
return str(value)
|
||||
|
||||
|
||||
def _build_rag_text(snippet: Dict[str, Any]) -> str:
|
||||
# Deterministic text concatenation for embedding input.
|
||||
parts: List[str] = []
|
||||
@ -512,7 +524,8 @@ def _prepare_rag_payloads(
|
||||
continue
|
||||
rag_item_id = _stable_rag_item_id(table_id, version_ts, snippet_id)
|
||||
rag_text = _build_rag_text(snippet)
|
||||
merged_json = json.dumps(snippet, ensure_ascii=False)
|
||||
serializable_snippet = _to_serializable(snippet)
|
||||
merged_json = json.dumps(serializable_snippet, ensure_ascii=False)
|
||||
updated_at_raw = snippet.get("updated_at_from_action") or now
|
||||
if isinstance(updated_at_raw, str):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user