config yaml package
This commit is contained in:
parent
ba772ff55b
commit
5092f286a5
8 changed files with 74 additions and 17 deletions
|
|
@ -98,7 +98,15 @@ export class AutocompleteLoggingService {
|
|||
private logAutocompleteOutcome(outcome: AutocompleteOutcome) {
|
||||
void DataLogger.getInstance().logDevData({
|
||||
name: "autocomplete",
|
||||
data: outcome,
|
||||
data: {
|
||||
...outcome,
|
||||
eventName: "autocomplete",
|
||||
createdAt: "",
|
||||
schemaVersion: "",
|
||||
userAgent: "",
|
||||
selectedProfileId: "",
|
||||
userId: "",
|
||||
},
|
||||
});
|
||||
|
||||
const { prompt, completion, prefix, suffix, ...restOfOutcome } = outcome;
|
||||
|
|
|
|||
|
|
@ -29,14 +29,49 @@ export class DataLogger {
|
|||
return DataLogger.instance;
|
||||
}
|
||||
|
||||
addBaseValues(body: object, schemaVersion: string): object {
|
||||
if ("createdAt" in body) {
|
||||
body.createdAt = new Date().toISOString();
|
||||
}
|
||||
if ("schemaVersion" in body) {
|
||||
body.schemaVersion = schemaVersion;
|
||||
}
|
||||
if ("userAgent" in body) {
|
||||
body.userAgent = navigator.userAgent; // TODO sufficient user agent info?
|
||||
}
|
||||
if ("selectedProfileId" in body) {
|
||||
body.selectedProfileId =
|
||||
this.core?.configHandler.currentProfile.profileDescription.id ?? "";
|
||||
}
|
||||
if ("userId" in body) {
|
||||
body.userId = "not-implemented";
|
||||
}
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
async logDevData(event: DevDataLogEvent) {
|
||||
// Local logs (always on for all levels)
|
||||
const filepath: string = getDevDataFilePath(
|
||||
event.name,
|
||||
LOCAL_DEV_DATA_VERSION,
|
||||
);
|
||||
const jsonLine = JSON.stringify(event.data);
|
||||
fs.writeFileSync(filepath, `${jsonLine}\n`, { flag: "a" });
|
||||
try {
|
||||
const filepath: string = getDevDataFilePath(
|
||||
event.name,
|
||||
LOCAL_DEV_DATA_VERSION,
|
||||
);
|
||||
const localSchema =
|
||||
devDataVersionedSchemas[LOCAL_DEV_DATA_VERSION]["all"][event.name];
|
||||
const parsed = localSchema?.safeParse(event.data);
|
||||
if (parsed?.success) {
|
||||
const withBaseValues = this.addBaseValues(
|
||||
parsed.data,
|
||||
LOCAL_DEV_DATA_VERSION,
|
||||
);
|
||||
fs.writeFileSync(filepath, `${JSON.stringify(withBaseValues)}\n`, {
|
||||
flag: "a",
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error logging local dev data:", error);
|
||||
}
|
||||
|
||||
// Remote logs
|
||||
const config = (await this.core?.configHandler.loadConfig())?.config;
|
||||
|
|
@ -83,6 +118,9 @@ export class DataLogger {
|
|||
);
|
||||
}
|
||||
|
||||
// Add base values like createdAt etc. if keys present in body
|
||||
const payload = this.addBaseValues(parsed.data, schemaVersion);
|
||||
|
||||
const uriComponents = URI.parse(dataConfig.destination);
|
||||
|
||||
// Send to remote server
|
||||
|
|
@ -113,7 +151,7 @@ export class DataLogger {
|
|||
headers,
|
||||
body: JSON.stringify({
|
||||
name: event.name,
|
||||
data: parsed.data,
|
||||
data: payload,
|
||||
schemaVersion,
|
||||
level,
|
||||
profileId,
|
||||
|
|
|
|||
|
|
@ -346,6 +346,13 @@ export abstract class BaseLLM implements ILLM {
|
|||
provider: this.providerName,
|
||||
promptTokens: promptTokens,
|
||||
generatedTokens: generatedTokens,
|
||||
|
||||
eventName: "tokensGenerated",
|
||||
createdAt: "",
|
||||
schemaVersion: "",
|
||||
userAgent: "",
|
||||
selectedProfileId: "",
|
||||
userId: "",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,18 @@ export default function FeedbackButtons({ item }: FeedbackButtonsProps) {
|
|||
for (const promptLog of item.promptLogs) {
|
||||
ideMessenger.post("devdata/log", {
|
||||
name: "chatFeedback",
|
||||
data: { ...promptLog, feedback, sessionId },
|
||||
data: {
|
||||
...promptLog,
|
||||
feedback,
|
||||
sessionId,
|
||||
|
||||
eventName: "chatFeedback",
|
||||
createdAt: "",
|
||||
schemaVersion: "",
|
||||
userAgent: "",
|
||||
selectedProfileId: "",
|
||||
userId: "",
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,9 @@ export const autocompleteEventSchema_0_2_0 = autocompleteEventAllSchema.pick({
|
|||
createdAt: true,
|
||||
userId: true,
|
||||
userAgent: true,
|
||||
platform: true,
|
||||
selectedProfileId: true,
|
||||
eventName: true,
|
||||
schemaVersion: true,
|
||||
sessionId: true,
|
||||
|
||||
// autocomplete-specific
|
||||
disable: true,
|
||||
|
|
|
|||
|
|
@ -3,11 +3,9 @@ import { z } from "zod";
|
|||
export const baseDevDataAllSchema = z.object({
|
||||
eventName: z.string(),
|
||||
schemaVersion: z.string(),
|
||||
sessionId: z.string(),
|
||||
createdAt: z.string(),
|
||||
userId: z.string(),
|
||||
userAgent: z.string(),
|
||||
platform: z.string(),
|
||||
selectedProfileId: z.string(),
|
||||
// gitCommitHash: z.string(),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,17 +5,16 @@ export const chatFeedbackEventSchema_0_2_0 = chatFeedbackEventAllSchema.pick({
|
|||
createdAt: true,
|
||||
userId: true,
|
||||
userAgent: true,
|
||||
platform: true,
|
||||
selectedProfileId: true,
|
||||
eventName: true,
|
||||
schemaVersion: true,
|
||||
sessionId: true,
|
||||
|
||||
// other
|
||||
prompt: true,
|
||||
completion: true,
|
||||
modelTitle: true,
|
||||
feedback: true,
|
||||
sessionId: true,
|
||||
});
|
||||
|
||||
export const chatFeedbackEventSchema_0_2_0_noPII =
|
||||
|
|
|
|||
|
|
@ -6,11 +6,9 @@ export const tokensGeneratedEventSchema_0_2_0 =
|
|||
createdAt: true,
|
||||
userId: true,
|
||||
userAgent: true,
|
||||
platform: true,
|
||||
selectedProfileId: true,
|
||||
eventName: true,
|
||||
schemaVersion: true,
|
||||
sessionId: true,
|
||||
|
||||
// tokens generated specific
|
||||
model: true,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue