2024-07-06 14:19:33 +05:30
|
|
|
import { ChatOpenAI } from '@langchain/openai';
|
|
|
|
import { getGroqApiKey } from '../../config';
|
|
|
|
import logger from '../../utils/logger';
|
|
|
|
|
|
|
|
export const loadGroqChatModels = async () => {
|
|
|
|
const groqApiKey = getGroqApiKey();
|
|
|
|
|
2024-07-08 15:39:27 +05:30
|
|
|
if (!groqApiKey) return {};
|
|
|
|
|
2024-07-06 14:19:33 +05:30
|
|
|
try {
|
|
|
|
const chatModels = {
|
2024-07-23 20:49:17 +05:30
|
|
|
'Llama 3.1 70B': new ChatOpenAI(
|
|
|
|
{
|
|
|
|
openAIApiKey: groqApiKey,
|
|
|
|
modelName: 'llama-3.1-70b-versatile',
|
|
|
|
temperature: 0.7,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
baseURL: 'https://api.groq.com/openai/v1',
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'Llama 3.1 8B': new ChatOpenAI(
|
|
|
|
{
|
|
|
|
openAIApiKey: groqApiKey,
|
|
|
|
modelName: 'llama-3.1-8b-instant',
|
|
|
|
temperature: 0.7,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
baseURL: 'https://api.groq.com/openai/v1',
|
|
|
|
},
|
|
|
|
),
|
2024-07-06 14:19:33 +05:30
|
|
|
'LLaMA3 8b': new ChatOpenAI(
|
|
|
|
{
|
|
|
|
openAIApiKey: groqApiKey,
|
|
|
|
modelName: 'llama3-8b-8192',
|
|
|
|
temperature: 0.7,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
baseURL: 'https://api.groq.com/openai/v1',
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'LLaMA3 70b': new ChatOpenAI(
|
|
|
|
{
|
|
|
|
openAIApiKey: groqApiKey,
|
|
|
|
modelName: 'llama3-70b-8192',
|
|
|
|
temperature: 0.7,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
baseURL: 'https://api.groq.com/openai/v1',
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'Mixtral 8x7b': new ChatOpenAI(
|
|
|
|
{
|
|
|
|
openAIApiKey: groqApiKey,
|
|
|
|
modelName: 'mixtral-8x7b-32768',
|
|
|
|
temperature: 0.7,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
baseURL: 'https://api.groq.com/openai/v1',
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'Gemma 7b': new ChatOpenAI(
|
|
|
|
{
|
|
|
|
openAIApiKey: groqApiKey,
|
|
|
|
modelName: 'gemma-7b-it',
|
|
|
|
temperature: 0.7,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
baseURL: 'https://api.groq.com/openai/v1',
|
|
|
|
},
|
|
|
|
),
|
2024-07-11 20:35:54 -07:00
|
|
|
'Gemma2 9b': new ChatOpenAI(
|
|
|
|
{
|
|
|
|
openAIApiKey: groqApiKey,
|
|
|
|
modelName: 'gemma2-9b-it',
|
|
|
|
temperature: 0.7,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
baseURL: 'https://api.groq.com/openai/v1',
|
|
|
|
},
|
|
|
|
),
|
2024-07-06 14:19:33 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
return chatModels;
|
|
|
|
} catch (err) {
|
|
|
|
logger.error(`Error loading Groq models: ${err}`);
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
};
|