diff options
Diffstat (limited to 'src/claude.ts')
| -rw-r--r-- | src/claude.ts | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/claude.ts b/src/claude.ts index 377316e..2a56bc1 100644 --- a/src/claude.ts +++ b/src/claude.ts @@ -1,20 +1,30 @@ import Claude from "@anthropic-ai/sdk"; import { RESPONSE_LENGTH } from "./logic/constants"; -import type { AResult, ChatMessage, OChoice, OChunk, OMessage } from "./types"; +import type { + AIModelAPI, + ChatMessage, + OChoice, + OChunk, + OMessage, +} from "./types"; import { BOOKWORM_SYS } from "./prompts"; +import type { AsyncRes } from "sortug"; type Message = Claude.Messages.MessageParam; -export default class Conversation { - private tokenizer: (text: string) => number; - private maxTokens: number; - model: string = "claude-3-5-sonnet-20241022"; +export default class ClaudeAPI implements AIModelAPI { + private model: string = "claude-3-7-sonnet-20250219"; + tokenizer: (text: string) => number; + maxTokens: number; + // model: string = "claude-3-5-sonnet-20241022"; constructor( maxTokens = 200_000, tokenizer: (text: string) => number = (text) => text.length / 3, + model?: string, ) { this.maxTokens = maxTokens; this.tokenizer = tokenizer; + if (model) this.model = model; } public setModel(model: string) { this.model = model; @@ -101,7 +111,7 @@ export default class Conversation { system: string, messages: Message[], isR1: boolean = false, - ): Promise<AResult<string[]>> { + ): Promise<AsyncRes<string[]>> { try { const claud = new Claude(); // const list = await claud.models.list(); |
