forked from phoenix/litellm-mirror
(feat) API custom callbacks
This commit is contained in:
parent
47b8715d25
commit
aa333161a8
2 changed files with 6 additions and 3 deletions
|
@ -7,6 +7,7 @@ app = FastAPI()
|
|||
@app.post("/log-event")
|
||||
async def log_event(request: Request):
|
||||
try:
|
||||
print("Received /log-event request")
|
||||
# Assuming the incoming request has JSON data
|
||||
data = await request.json()
|
||||
print("Received request data:")
|
||||
|
@ -18,6 +19,9 @@ async def log_event(request: Request):
|
|||
return {"message": "Request received successfully"}
|
||||
except Exception as e:
|
||||
print(f"Error processing request: {str(e)}")
|
||||
import traceback
|
||||
|
||||
traceback.print_exc()
|
||||
raise HTTPException(status_code=500, detail="Internal Server Error")
|
||||
|
||||
|
||||
|
|
|
@ -106,15 +106,14 @@ class GenericAPILogger:
|
|||
|
||||
import json
|
||||
|
||||
payload = json.dumps(payload)
|
||||
data = {
|
||||
"data": payload,
|
||||
}
|
||||
|
||||
data = json.dumps(data)
|
||||
print_verbose(f"\nGeneric Logger - Logging payload = {data}")
|
||||
|
||||
# make request to endpoint with payload
|
||||
response = requests.post(self.endpoint, data=data, headers=self.headers)
|
||||
response = requests.post(self.endpoint, json=data, headers=self.headers)
|
||||
|
||||
response_status = response.status_code
|
||||
response_text = response.text
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue