MCPcopy Create free account
hub / github.com/caesarHQ/textSQL / log_apicall_failure

Function log_apicall_failure

api/app/api/utils/caesar_logging.py:50–76  ·  view source on GitHub ↗
(duration, provider, model, input_tokens, service, purpose, session_id=None)

Source from the content-addressed store, hash-verified

48
49@failsoft
50def log_apicall_failure(duration, provider, model, input_tokens, service, purpose, session_id=None):
51 if not EVENTS_ENGINE:
52 return {"status": "no engine"}
53
54 params = {
55 "duration": duration,
56 "provider": provider,
57 "model": model,
58 "input_tokens": input_tokens,
59 "output_tokens": 0,
60 "service": service,
61 "purpose": purpose,
62 "cost": 0,
63 "success": "false",
64 "session_id": session_id,
65 }
66
67 insert_query = text("""
68 INSERT INTO apicalls (duration, provider, model, input_tokens, output_tokens, service, purpose, cost, success, session_id)
69 VALUES (:duration, :provider, :model, :input_tokens, :output_tokens, :service, :purpose, :cost, :success, :session_id)
70 """)
71
72 with EVENTS_ENGINE.connect() as conn:
73 conn.execute(insert_query, params)
74 conn.commit()
75
76 return {"status": "success"}
77
78
79

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected