From 42dd99bfac9777a4ecc6700b87edf26a5c984de6 Mon Sep 17 00:00:00 2001 From: polwex Date: Wed, 23 Jul 2025 02:37:15 +0700 Subject: checkpoint --- src/claude.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/claude.ts') 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> { + ): Promise> { try { const claud = new Claude(); // const list = await claud.models.list(); -- cgit v1.2.3