-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ecad065
commit 1777462
Showing
8 changed files
with
151 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { | ||
ChatGoogleGenerativeAI, | ||
GoogleGenerativeAIEmbeddings, | ||
} from '@langchain/google-genai'; | ||
import { getGeminiApiKey } from '../../config'; | ||
import logger from '../../utils/logger'; | ||
|
||
export const loadGeminiChatModels = async () => { | ||
const geminiApiKey = getGeminiApiKey(); | ||
|
||
if (!geminiApiKey) return {}; | ||
|
||
try { | ||
const chatModels = { | ||
'gemini-1.5-flash': { | ||
displayName: 'Gemini 1.5 Flash', | ||
model: new ChatGoogleGenerativeAI({ | ||
modelName: 'gemini-1.5-flash', | ||
temperature: 0.7, | ||
apiKey: geminiApiKey, | ||
}), | ||
}, | ||
'gemini-1.5-flash-8b': { | ||
displayName: 'Gemini 1.5 Flash 8B', | ||
model: new ChatGoogleGenerativeAI({ | ||
modelName: 'gemini-1.5-flash-8b', | ||
temperature: 0.7, | ||
apiKey: geminiApiKey, | ||
}), | ||
}, | ||
'gemini-1.5-pro': { | ||
displayName: 'Gemini 1.5 Pro', | ||
model: new ChatGoogleGenerativeAI({ | ||
modelName: 'gemini-1.5-pro', | ||
temperature: 0.7, | ||
apiKey: geminiApiKey, | ||
}), | ||
}, | ||
}; | ||
|
||
return chatModels; | ||
} catch (err) { | ||
logger.error(`Error loading Gemini models: ${err}`); | ||
return {}; | ||
} | ||
}; | ||
|
||
export const loadGeminiEmbeddingsModels = async () => { | ||
const geminiApiKey = getGeminiApiKey(); | ||
|
||
if (!geminiApiKey) return {}; | ||
|
||
try { | ||
const embeddingModels = { | ||
'text-embedding-004': { | ||
displayName: 'Text Embedding', | ||
model: new GoogleGenerativeAIEmbeddings({ | ||
apiKey: geminiApiKey, | ||
modelName: 'text-embedding-004', | ||
}), | ||
}, | ||
}; | ||
|
||
return embeddingModels; | ||
} catch (err) { | ||
logger.error(`Error loading Gemini embeddings model: ${err}`); | ||
return {}; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters