-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathschemas.ts
More file actions
76 lines (64 loc) · 1.68 KB
/
schemas.ts
File metadata and controls
76 lines (64 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { z } from "zod";
export const llmMessageSchema = z.object({
role: z.enum(["user", "assistant"]),
content: z.string(),
});
export type LlmMessage = z.infer<typeof llmMessageSchema>;
export const promptInput = z.object({
system: z.string().optional(),
messages: z.array(llmMessageSchema),
maxTokens: z.number().optional(),
model: z.string().default("claude-haiku-4-5"),
});
export type PromptInput = z.infer<typeof promptInput>;
export const promptOutput = z.object({
content: z.string(),
model: z.string(),
stopReason: z.string().nullable(),
usage: z.object({
inputTokens: z.number(),
outputTokens: z.number(),
}),
});
export type PromptOutput = z.infer<typeof promptOutput>;
export interface AnthropicMessagesRequest {
model: string;
messages: Array<{ role: "user" | "assistant"; content: string }>;
max_tokens?: number;
system?: string;
stream?: boolean;
}
export interface AnthropicMessagesResponse {
id: string;
type: "message";
role: "assistant";
content: Array<{ type: "text"; text: string }>;
model: string;
stop_reason: string | null;
usage: {
input_tokens: number;
output_tokens: number;
};
}
export interface AnthropicErrorResponse {
error: {
message: string;
type: string;
code?: string;
};
}
export const usageBucketSchema = z.object({
used_usd: z.number(),
limit_usd: z.number(),
remaining_usd: z.number(),
resets_in_seconds: z.number(),
exceeded: z.boolean(),
});
export const usageOutput = z.object({
product: z.string(),
user_id: z.number(),
sustained: usageBucketSchema,
burst: usageBucketSchema,
is_rate_limited: z.boolean(),
});
export type UsageOutput = z.infer<typeof usageOutput>;