feat: meter AI usage
CI and Deploy / test (push) Failing after 58s
CI and Deploy / deploy (push) Has been skipped

This commit is contained in:
cesnimda
2026-07-30 22:39:24 +02:00
parent f8466c2ebc
commit c08232b9d7
15 changed files with 2482 additions and 11 deletions
+6
View File
@@ -10,6 +10,11 @@ export type AiInteraction = {
createdAtUtc: string;
};
export type AiUsage = {
currentMonth: { calls: number; inputCharacters: number; outputCharacters: number; estimatedTokens: number };
allTime: { calls: number; inputCharacters: number; outputCharacters: number; estimatedTokens: number };
};
export const AI_MODULES: { key: string; label: string; blurb: string }[] = [
{ key: "job-analysis", label: "Job Analysis", blurb: "Break down the advert: skills, requirements, salary, work model, interview topics." },
{ key: "career-match", label: "Career Match", blurb: "Your profile vs the advert: strengths, gaps, match %, suggested improvements." },
@@ -21,6 +26,7 @@ export const AI_MODULES: { key: string; label: string; blurb: string }[] = [
export const COVER_LETTER_MODES = ["professional", "friendly", "short", "detailed", "modern", "traditional"];
export const aiWorkspaceApi = {
usage: () => api.get<AiUsage>("/ai/usage").then((r) => r.data),
modules: (jobId: number) => api.get<{ modules: string[]; provider: string }>(`/jobapplications/${jobId}/ai/modules`).then((r) => r.data),
generate: (jobId: number, body: { module: string; mode?: string; extraContext?: string }) =>
api.post<AiInteraction>(`/jobapplications/${jobId}/ai/generate`, body).then((r) => r.data),