File size: 1,694 Bytes
a80ecb8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { ChatAnthropic } from '@langchain/anthropic';
import { getAnthropicApiKey } from '../../config';
import logger from '../../utils/logger';

export const loadAnthropicChatModels = async () => {
  const anthropicApiKey = getAnthropicApiKey();

  if (!anthropicApiKey) return {};

  try {
    const chatModels = {
      'claude-3-5-sonnet-20241022': {
        displayName: 'Claude 3.5 Sonnet',
        model: new ChatAnthropic({
          temperature: 0.7,
          anthropicApiKey: anthropicApiKey,
          model: 'claude-3-5-sonnet-20241022',
        }),
      },
      'claude-3-5-haiku-20241022': {
        displayName: 'Claude 3.5 Haiku',
        model: new ChatAnthropic({
          temperature: 0.7,
          anthropicApiKey: anthropicApiKey,
          model: 'claude-3-5-haiku-20241022',
        }),
      },
      'claude-3-opus-20240229': {
        displayName: 'Claude 3 Opus',
        model: new ChatAnthropic({
          temperature: 0.7,
          anthropicApiKey: anthropicApiKey,
          model: 'claude-3-opus-20240229',
        }),
      },
      'claude-3-sonnet-20240229': {
        displayName: 'Claude 3 Sonnet',
        model: new ChatAnthropic({
          temperature: 0.7,
          anthropicApiKey: anthropicApiKey,
          model: 'claude-3-sonnet-20240229',
        }),
      },
      'claude-3-haiku-20240307': {
        displayName: 'Claude 3 Haiku',
        model: new ChatAnthropic({
          temperature: 0.7,
          anthropicApiKey: anthropicApiKey,
          model: 'claude-3-haiku-20240307',
        }),
      },
    };

    return chatModels;
  } catch (err) {
    logger.error(`Error loading Anthropic models: ${err}`);
    return {};
  }
};