feat: meter AI usage
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user