jakethekoenig / llm-chat

A library of components for making llm chats
1 stars 0 forks source link

Support anthropic models #111

Open jakethekoenig opened 4 days ago

jakethekoenig commented 4 days ago

We should detect that the user entered an anthropic model and instead use anthropic's api:

import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic({
  apiKey: process.env['ANTHROPIC_API_KEY'], // This is the default and can be omitted
});

async function main() {
  const message = await client.messages.create({
    max_tokens: 1024,
    messages: [{ role: 'user', content: 'Hello, Claude' }],
    model: 'claude-3-opus-20240229',
  });

  console.log(message.content);
}

It's currently on version 0.29.0. We can detect it's an anthropic model by checking if it contains any of the strings: claude/sonnet/haiku/opus for now.

jakethekoenig commented 3 days ago

@mentatbot

mentatbot[bot] commented 3 days ago

I will start working on this issue