phase-7: code restructure
This commit is contained in:
committed by
saikiranvella
parent
c160e65bd6
commit
357b0c0f6e
@@ -0,0 +1,31 @@
|
||||
import Anthropic from '@anthropic-ai/sdk';
|
||||
|
||||
/**
|
||||
* Thin wrapper around the Anthropic SDK.
|
||||
* Handles initialisation and raw message completion only —
|
||||
* prompt construction and response parsing stay in LLMAnalyst (service layer).
|
||||
*/
|
||||
export class AnthropicClient {
|
||||
private client: Anthropic | null;
|
||||
|
||||
constructor() {
|
||||
this.client = process.env.ANTHROPIC_API_KEY
|
||||
? new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY })
|
||||
: null;
|
||||
}
|
||||
|
||||
get isAvailable(): boolean {
|
||||
return this.client !== null;
|
||||
}
|
||||
|
||||
async complete(system: string, userMessage: string): Promise<string | null> {
|
||||
if (!this.client) return null;
|
||||
const response = await this.client.messages.create({
|
||||
model: 'claude-haiku-4-5',
|
||||
max_tokens: 1024,
|
||||
system,
|
||||
messages: [{ role: 'user', content: userMessage }],
|
||||
});
|
||||
return (response.content[0] as { text?: string })?.text ?? null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user