summaryrefslogtreecommitdiff
path: root/src/claude.ts
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-07-23 02:37:15 +0700
committerpolwex <polwex@sortug.com>2025-07-23 02:37:15 +0700
commit42dd99bfac9777a4ecc6700b87edf26a5c984de6 (patch)
tree031e45d187f45def4b58ad7590d39dec3924600d /src/claude.ts
parent4c6913644b362b28f15b125c2fbe48165f1e048c (diff)
checkpoint
Diffstat (limited to 'src/claude.ts')
-rw-r--r--src/claude.ts22
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();