Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interacting Telemetry [2/n]: Hook up mutable AIConfig events to datadog logger #1220

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ function AIConfigEditorBase({
};

dispatch(action);
logEventHandler?.("UPDATE_PROMPT_INPUT");

const onError = (err: unknown) => {
const message = (err as RequestCallbackError).message ?? null;
Expand Down Expand Up @@ -313,7 +314,7 @@ function AIConfigEditorBase({
onError(err);
}
},
[debouncedUpdatePrompt, dispatch, showNotification]
[debouncedUpdatePrompt, dispatch, logEventHandler, showNotification]
);

const onChangePromptName = useCallback(
Expand Down Expand Up @@ -349,19 +350,21 @@ function AIConfigEditorBase({
// PromptName component maintains local state for the name to show in the UI
// We cannot update client config state until the name is successfully set server-side
// or else we could end up referencing a prompt name that is not set server-side
() =>
() => {
dispatch({
type: "UPDATE_PROMPT_NAME",
id: promptId,
name: newName,
}),
});
logEventHandler?.("UPDATE_PROMPT_NAME");
},
onError
);
} catch (err: unknown) {
onError(err);
}
},
[debouncedUpdatePrompt, showNotification]
[debouncedUpdatePrompt, logEventHandler, showNotification]
);

const updateModelCallback = callbacks?.updateModel;
Expand Down Expand Up @@ -402,6 +405,7 @@ function AIConfigEditorBase({
id: promptId,
modelSettings: newModelSettings,
});
logEventHandler?.("UPDATE_PROMPT_MODEL_SETTINGS");

const onError = (err: unknown) => {
const message = (err as RequestCallbackError).message ?? null;
Expand Down Expand Up @@ -436,7 +440,7 @@ function AIConfigEditorBase({
onError(err);
}
},
[debouncedUpdateModel, dispatch, showNotification]
[debouncedUpdateModel, dispatch, logEventHandler, showNotification]
);

const onUpdatePromptModel = useCallback(
Expand All @@ -452,6 +456,7 @@ function AIConfigEditorBase({
id: promptId,
modelName: newModel,
});
logEventHandler?.("UPDATE_PROMPT_MODEL", { model: newModel });

const onError = (err: unknown) => {
const message = (err as RequestCallbackError).message ?? null;
Expand Down Expand Up @@ -479,7 +484,7 @@ function AIConfigEditorBase({
onError(err);
}
},
[dispatch, debouncedUpdateModel, showNotification]
[dispatch, debouncedUpdateModel, logEventHandler, showNotification]
);

const setParametersCallback = callbacks?.setParameters;
Expand Down Expand Up @@ -516,6 +521,7 @@ function AIConfigEditorBase({
type: "UPDATE_GLOBAL_PARAMETERS",
parameters: newParameters,
});
logEventHandler?.("UPDATE_GLOBAL_PARAMETERS");

const onError = (err: unknown) => {
const message = (err as RequestCallbackError).message ?? null;
Expand All @@ -536,7 +542,7 @@ function AIConfigEditorBase({
onError(err);
}
},
[debouncedSetParameters, dispatch, showNotification]
[debouncedSetParameters, dispatch, logEventHandler, showNotification]
);

const onUpdatePromptParameters = useCallback(
Expand All @@ -552,6 +558,7 @@ function AIConfigEditorBase({
id: promptId,
parameters: newParameters,
});
logEventHandler?.("UPDATE_PROMPT_PARAMETERS");

const onError = (err: unknown) => {
const message = (err as RequestCallbackError).message ?? null;
Expand All @@ -574,7 +581,7 @@ function AIConfigEditorBase({
onError(err);
}
},
[debouncedSetParameters, dispatch, showNotification]
[debouncedSetParameters, dispatch, logEventHandler, showNotification]
);

const addPromptCallback = callbacks?.addPrompt;
Expand Down Expand Up @@ -648,6 +655,7 @@ function AIConfigEditorBase({
type: "DELETE_PROMPT",
id: promptId,
});
logEventHandler?.("DELETE_PROMPT");

try {
const prompt = getPrompt(stateRef.current, promptId);
Expand All @@ -664,7 +672,7 @@ function AIConfigEditorBase({
});
}
},
[deletePromptCallback, dispatch, showNotification]
[deletePromptCallback, dispatch, logEventHandler, showNotification]
);

const clearOutputsCallback = callbacks?.clearOutputs;
Expand All @@ -678,6 +686,8 @@ function AIConfigEditorBase({
dispatch({
type: "CLEAR_OUTPUTS",
});
logEventHandler?.("CLEAR_OUTPUTS");

try {
await clearOutputsCallback();
} catch (err: unknown) {
Expand All @@ -688,7 +698,7 @@ function AIConfigEditorBase({
type: "error",
});
}
}, [clearOutputsCallback, dispatch, showNotification]);
}, [clearOutputsCallback, dispatch, logEventHandler, showNotification]);

const runPromptCallback = callbacks?.runPrompt;

Expand Down Expand Up @@ -844,6 +854,7 @@ function AIConfigEditorBase({
type: "SET_NAME",
name,
});
logEventHandler?.("SET_NAME");

await debouncedSetName(name, (err: unknown) => {
const message = (err as RequestCallbackError).message ?? null;
Expand All @@ -854,7 +865,7 @@ function AIConfigEditorBase({
});
});
},
[debouncedSetName, showNotification]
[debouncedSetName, logEventHandler, showNotification]
);

const setDescriptionCallback = callbacks?.setConfigDescription;
Expand Down Expand Up @@ -887,6 +898,7 @@ function AIConfigEditorBase({
type: "SET_DESCRIPTION",
description,
});
logEventHandler?.("SET_DESCRIPTION");

await debouncedSetDescription(description, (err: unknown) => {
const message = (err as RequestCallbackError).message ?? null;
Expand All @@ -897,7 +909,7 @@ function AIConfigEditorBase({
});
});
},
[debouncedSetDescription, showNotification]
[debouncedSetDescription, logEventHandler, showNotification]
);

const getState = useCallback(() => stateRef.current, []);
Expand Down
12 changes: 11 additions & 1 deletion python/src/aiconfig/editor/client/src/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,23 @@ export function aiConfigToClientConfig(aiconfig: AIConfig): ClientAIConfig {

export type LogEvent =
| "ADD_PROMPT"
| "CLEAR_OUTPUTS"
| "DELETE_PROMPT"
| "DOWNLOAD_BUTTON_CLICKED"
| "RUN_PROMPT_CANCELED"
| "RUN_PROMPT_ERROR"
| "RUN_PROMPT_START"
| "RUN_PROMPT_SUCCESS"
| "SAVE_BUTTON_CLICKED"
| "SHARE_BUTTON_CLICKED";
| "SET_DESCRIPTION"
| "SET_NAME"
| "SHARE_BUTTON_CLICKED"
| "UPDATE_GLOBAL_PARAMETERS"
| "UPDATE_PROMPT_INPUT"
| "UPDATE_PROMPT_MODEL"
| "UPDATE_PROMPT_MODEL_SETTINGS"
| "UPDATE_PROMPT_NAME"
| "UPDATE_PROMPT_PARAMETERS";

// TODO: schematize this
export type LogEventData = JSONObject;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"files": {
"main.js": "/static/js/main.e93da0c9.js",
"main.js": "/static/js/main.f838c843.js",
"index.html": "/index.html",
"main.e93da0c9.js.map": "/static/js/main.e93da0c9.js.map"
"main.f838c843.js.map": "/static/js/main.f838c843.js.map"
},
"entrypoints": [
"static/js/main.e93da0c9.js"
"static/js/main.f838c843.js"
]
}
2 changes: 1 addition & 1 deletion python/src/aiconfig/editor/server/static/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>AIConfig Editor</title><script defer="defer" src="/static/js/main.e93da0c9.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>AIConfig Editor</title><script defer="defer" src="/static/js/main.f838c843.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading