Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Gemini 1.5 Flash ⚡️ #275

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions vscode/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"properties": {
"fluttergpt.apiKey": {
"type": "string",
"markdownDescription": "Gemini API KEY(https://makersuite.google.com/)"
"markdownDescription": "CommandDash Gemini API KEY(https://makersuite.google.com/)"
}
}
},
Expand Down Expand Up @@ -293,7 +293,7 @@
"typescript": "^5.0.4"
},
"dependencies": {
"@google/generative-ai": "^0.1.1",
"@google/generative-ai": "0.11.1",
"@vscode/extension-telemetry": "^0.8.1",
"axios": "^1.4.0",
"dotenv": "^16.3.1",
Expand Down
15 changes: 10 additions & 5 deletions vscode/src/repository/gemini-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,26 @@ export class GeminiRepository extends GenerationRepository {
let lastMessage = prompt.pop();

// Count the tokens in the prompt
const model = this.genAI.getGenerativeModel({ model: "gemini-pro" });
const model = this.genAI.getGenerativeModel({ model: "gemini-pro" }); //TODO: upgrade this to flash model
let promptText = "";
prompt.forEach(p => promptText += p.parts);
const { totalTokens } = await model.countTokens(promptText);
console.log("Total input tokens: " + totalTokens);

// Check if the token count exceeds the limit
if (totalTokens > 30720) {
if (totalTokens > 1040384) {
throw Error('Input prompt exceeds the maximum token limit.');
}

const chat = this.genAI.getGenerativeModel({ model: "gemini-pro", generationConfig: { temperature: 0.0, topP: 0.2 } }).startChat(
const chat = this.genAI.getGenerativeModel({ model: "gemini-1.5-flash-latest", generationConfig: { temperature: 0.0, topP: 0.2 } }).startChat(
{
history: prompt, generationConfig: {
maxOutputTokens: 2048,
history: prompt.map(p => {
return {
role: p.role,
parts: [{ text: p.parts }]
};
}), generationConfig: {
maxOutputTokens: 8192,
},
}
);
Expand Down
Loading