Skip to content

Commit fed7240

Browse files
authored
fix(langchain): set cost to zero on errors (#1328)
1 parent a4d5d72 commit fed7240

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

langfuse/langchain/CallbackHandler.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ def on_retriever_error(
218218
level="ERROR",
219219
status_message=str(error),
220220
input=kwargs.get("inputs"),
221+
cost_details={"total": 0},
221222
).end()
222223

223224
except Exception as e:
@@ -527,6 +528,7 @@ def on_chain_error(
527528
),
528529
status_message=str(error) if level else None,
529530
input=kwargs.get("inputs"),
531+
cost_details={"total": 0},
530532
).end()
531533

532534
except Exception as e:
@@ -733,6 +735,7 @@ def on_tool_error(
733735
status_message=str(error),
734736
level="ERROR",
735737
input=kwargs.get("inputs"),
738+
cost_details={"total": 0},
736739
).end()
737740

738741
except Exception as e:
@@ -913,6 +916,7 @@ def on_llm_error(
913916
status_message=str(error),
914917
level="ERROR",
915918
input=kwargs.get("inputs"),
919+
cost_details={"total": 0},
916920
).end()
917921

918922
except Exception as e:

0 commit comments

Comments
 (0)