User:Polygnotus/Scripts/GeminiProofreaderOld.js: Difference between revisions

Content deleted Content added
Cramulator (talk | contribs)
Created page with '(function() { // based on https://en.wikipedia.org/wiki/User:Polygnotus/Scripts/Claude6.js 'use strict'; class WikipediaGeminiProofreader { constructor() { this.apiKey = localStorage.getItem('gemini_api_key'); this.sidebarWidth = localStorage.getItem('gemini_sidebar_width') || '350px'; this.isVisible = localStorage.getItem('gemini_sidebar_visible') !== 'false'; this.currentResults = localStora...'
 
 
(6 intermediate revisions by 2 users not shown)
Line 1:
(function() { // based on https://en.wikipedia.org/wiki/User:Polygnotus/Scripts/Claude6.js
// instructions: add the following to your User/common.js file
(function() {
'use strict';
class WikipediaGeminiProofreader {
Line 8 ⟶ 10:
this.currentResults = localStorage.getItem('gemini_current_results') || '';
this.buttons = {};
this.modelName = 'gemini-2.5-proflash-preview-05-20'; // Asbest requestedwith forfree mid-2025tier
this.init();
}
Line 446 ⟶ 448:
title: 'Set Gemini API Key', // Changed
message: $('<div>').append(
$('<p>').texthtml('Enter <a href="https://aistudio.google.com/app/apikey" target="_blank">your free Gemini API Key</a> to enable proofreading:'), // Changed
textInput.$element
),
Line 591 ⟶ 593:
if (!wikicode) {
throw new Error('Could not fetch article wikicode');
}
 
if (wikicode.length > 100000) { // Gemini models have input limits, e.g. 1.5 Pro has large context
const confirmed = await new Promise(resolve => {
OO.ui.confirm(`This article is quite long (${wikicode.length} characters). Processing may take a while and use significant API credits. Continue?`)
.done(resolve);
});
 
if (!confirmed) {
this.updateStatus('Operation cancelled by user.');
this.buttons.proofread.setDisabled(false);
return;
}
}
 
Line 611 ⟶ 600:
 
this.updateStatus('Proofreading complete!');
const finalOutput = `${articleTitle}:\n${result}`; // Prepend title to proofreading
this.updateOutput(result, true); // Assume Gemini returns markdown-like text
this.updateOutput(finalOutput, true);
 
} catch (error) {
Line 700 ⟶ 690:
contents: [{
parts: [{ "text": wikicode }],
// role: "user" // role is optional for single turn if not doing multi-turn chat
}],
systemInstruction: {
Line 706 ⟶ 696:
},
generationConfig: {
maxOutputTokens: 409665536, // Maxshould forbe Geminienough 1.0given Pro,1M 2.5 Pro might betoken higherwindow
temperature: 0.30, // For more factual, less creative output
// topP: 0.9}, // Adjust as needed
}tools: [
{urlContext: {}},
{googleSearch: {}},
],
};