log whether tool calls fail or succeed
This commit is contained in:
parent
43405bceac
commit
af24a851e3
1 changed files with 15 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { createAsyncThunk, unwrapResult } from "@reduxjs/toolkit";
|
||||
import { ContextItem } from "core";
|
||||
import { CLIENT_TOOLS_IMPLS } from "core/tools/builtIn";
|
||||
import posthog from "posthog-js";
|
||||
import { callClientTool } from "../../util/clientTools/callClientTool";
|
||||
import { selectCurrentToolCall } from "../selectors/selectCurrentToolCall";
|
||||
import { selectSelectedChatModel } from "../slices/configSlice";
|
||||
|
|
@ -45,6 +46,9 @@ export const callCurrentTool = createAsyncThunk<void, undefined, ThunkApiType>(
|
|||
let errorMessage: string | undefined = undefined;
|
||||
let streamResponse: boolean;
|
||||
|
||||
// Check if telemetry is enabled
|
||||
const allowAnonymousTelemetry = state.config.config.allowAnonymousTelemetry;
|
||||
|
||||
// IMPORTANT:
|
||||
// Errors that occur while calling tool call implementations
|
||||
// Are caught and passed in output as context items
|
||||
|
|
@ -110,6 +114,17 @@ export const callCurrentTool = createAsyncThunk<void, undefined, ThunkApiType>(
|
|||
);
|
||||
}
|
||||
|
||||
// Because we don't have access to use hooks, we check `allowAnonymousTelemetry`
|
||||
// directly rather than using `CustomPostHogProvider`
|
||||
if (allowAnonymousTelemetry) {
|
||||
// Capture telemetry for tool calls
|
||||
posthog.capture("gui_tool_call_outcome", {
|
||||
succeeded: errorMessage === undefined,
|
||||
toolName: toolCallState.toolCall.function.name,
|
||||
errorMessage: errorMessage,
|
||||
});
|
||||
}
|
||||
|
||||
if (streamResponse) {
|
||||
if (errorMessage) {
|
||||
dispatch(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue