Skip to content

Commit

Permalink
gemini
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaki-1052 committed May 30, 2024
1 parent bd8ac85 commit b98ae72
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
4 changes: 2 additions & 2 deletions public/portal.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<button id="model-claude-haiku" data-value="claude-3-haiku-20240307">Claude Haiku</button>
<button id="model-mistral-large" data-value="mistral-large-latest">Mistral Large</button>
<button id="model-llama-70b" data-value="llama3-70b-8192">Llama3 70b</button>
<button id="model-gemini-1.5-pro" data-value="gemini-1.5-pro">Gemini-1.5 Pro</button>
<button id="model-gemini-1.5-flash" data-value="gemini-1.5-flash">Gemini-1.5 Flash</button>
<button id="model-gemini-1.5-pro" data-value="gemini-1.5-pro-latest">Gemini-1.5 Pro</button>
<button id="model-gemini-1.5-flash" data-value="gemini-1.5-flash-latest">Gemini-1.5 Flash</button>
<button id="model-gemini-pro-vision" data-value="gemini-pro-vision">Gemini Pro Vision</button>
<button id="model-llama-8b" data-value="llama3-8b-8192">Llama3 8b</button>
<button id="model-gemma-it" data-value="gemma-7b-it">Gemma 7B</button>
Expand Down
14 changes: 7 additions & 7 deletions public/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ fetchConfig();
"GPT-3.5-Turbo": "gpt-3.5-turbo-0125",
"Gemini-Pro": "gemini-pro",
"Gemini-Pro-Vision": "gemini-pro-vision",
"Gemini-1.5-Pro": "gemini-1.5-pro",
"Gemini-1.5-Flash": "gemini-1.5-flash",
"Gemini-1.5-Pro": "gemini-1.5-pro-latest",
"Gemini-1.5-Flash": "gemini-1.5-flash-latest",
"Gemini-Ultra": "gemini-1.0-ultra",
"Claude-Opus": "claude-3-opus-20240229",
"Claude-Sonnet": "claude-3-sonnet-20240229",
Expand Down Expand Up @@ -196,8 +196,8 @@ fetchConfig();
"gpt-3.5-turbo-0125": "GPT-3.5-Turbo",
"gemini-pro": "Gemini-Pro",
"gemini-pro-vision": "Gemini-Pro-Vision",
"gemini-1.5-pro": "Gemini-1.5-Pro",
"gemini-1.5-flash": "Gemini-1.5-Flash",
"gemini-1.5-pro-latest": "Gemini-1.5-Pro",
"gemini-1.5-flash-latest": "Gemini-1.5-Flash",
"gemini-1.0-ultra": "Gemini-Ultra",
"claude-3-opus-20240229": "Claude-Opus",
"claude-3-sonnet-20240229": "Claude-Sonnet",
Expand Down Expand Up @@ -614,8 +614,8 @@ document.getElementById('model-gpt-3.5').addEventListener('mouseover', (event) =
// Event listeners for selecting Gemini models
document.getElementById('model-gemini-pro').addEventListener('click', () => selectModel('gemini-pro'));
document.getElementById('model-gemini-pro-vision').addEventListener('click', () => selectModel('gemini-pro-vision'));
document.getElementById('model-gemini-1.5-pro').addEventListener('click', () => selectModel('gemini-1.5-pro'));
document.getElementById('model-gemini-1.5-flash').addEventListener('click', () => selectModel('gemini-1.5-flash'));
document.getElementById('model-gemini-1.5-pro').addEventListener('click', () => selectModel('gemini-1.5-pro-latest'));
document.getElementById('model-gemini-1.5-flash').addEventListener('click', () => selectModel('gemini-1.5-flash-latest'));
document.getElementById('model-gemini-ultra').addEventListener('click', () => selectModel('gemini-1.0-ultra'));

// Event listeners for showing Gemini model descriptions on hover
Expand Down Expand Up @@ -1247,7 +1247,7 @@ async function uploadImageAndGetUrl(imageFile) {
};
endpoint = `${baseURL}/assistant`; // OpenAI endpoint
} else {
if (currentModelID.startsWith('gemini')) {
if (currentModelID.includes('gemini')) {
// Prepare the payload for Google Gemini API
payload = {
prompt: message,
Expand Down
8 changes: 1 addition & 7 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -893,13 +893,10 @@ geminiHistory += 'User Prompt: ' + prompt + '\n';

// Handle text-only input
if (!history && (!imageParts || imageParts.length === 0)) {
if (model !== 'gemini-pro') {
return res.status(400).json({ error: 'Invalid model for text-only input. Use gemini-pro.' });
}


// Initialize the Google model for text-only input
const googleModel = genAI.getGenerativeModel({ model: 'gemini-pro', generationConfig: defaultConfig, safetySettings });
const googleModel = genAI.getGenerativeModel({ model: model, generationConfig: defaultConfig, safetySettings });
// Generate content based on the geminiHistory
const result = await googleModel.generateContent(geminiHistory);

Expand All @@ -913,9 +910,6 @@ if (!history && (!imageParts || imageParts.length === 0)) {
}
// Handle text-and-image input (multimodal)
else if (imageParts && imageParts.length > 0 && !history) {
if (model !== 'gemini-pro-vision' && model !== 'gemini-1.5-pro') {
return res.status(400).json({ error: 'Invalid model for text-and-image input. Use gemini-pro-vision.' });
}

// Initialize the Google model for text-and-image input
const googleModel = genAI.getGenerativeModel({ model: model, generationConfig: defaultConfig, safetySettings });
Expand Down

0 comments on commit b98ae72

Please sign in to comment.