mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-24 01:15:24 +08:00
perf(llm): harden request policy and optimize connections, reasoning and prompt caching (#2661)
* fix(llm): centralize request policy and preserve stream diagnostics * test(llm): dispose SQLite engine after migration regression * perf(llm): reuse connections and unify reasoning and prompt cache policy * fix(llm): preserve explicit native prompt cache options * perf(llm): fix measured TLS setup and streaming reuse overhead * fix(llm): resolve plugin request-chain regressions found by E2E --------- Co-authored-by: Hyu <[email protected]>
This commit is contained in:
@@ -605,6 +605,7 @@ class MonitoringService(ExecutionDetailsMixin):
|
||||
cost: float | None = None,
|
||||
error_message: str | None = None,
|
||||
message_id: str | None = None,
|
||||
details: dict | None = None,
|
||||
) -> str:
|
||||
"""Record an LLM call"""
|
||||
workspace_uuid = self._require_write_context(context)
|
||||
@@ -616,7 +617,7 @@ class MonitoringService(ExecutionDetailsMixin):
|
||||
'model_name': model_name,
|
||||
'input_tokens': input_tokens,
|
||||
'output_tokens': output_tokens,
|
||||
'total_tokens': input_tokens + output_tokens,
|
||||
'total_tokens': ((details or {}).get('usage') or {}).get('total_tokens') or (input_tokens + output_tokens),
|
||||
'duration': duration,
|
||||
'cost': cost,
|
||||
'status': status,
|
||||
@@ -627,6 +628,7 @@ class MonitoringService(ExecutionDetailsMixin):
|
||||
'session_id': session_id,
|
||||
'error_message': error_message,
|
||||
'message_id': message_id,
|
||||
'details': details,
|
||||
}
|
||||
|
||||
await self.ap.persistence_mgr.execute_async(
|
||||
|
||||
Reference in New Issue
Block a user