Page MenuHomePhabricator

Have problem with migrating to LiftWing from ores
Open, Needs TriagePublic

Authored By
AgnesAbah
May 3 2024, 9:40 AM
Referenced Files
F55587909: image.png
Jun 22 2024, 4:21 PM
F49950657: 2.png
May 3 2024, 9:40 AM
F49950650: 1.png
May 3 2024, 9:40 AM

Description

Hey folks, just a bit of background for our technical issues. cc @Molly Stark Dean For several years now we’ve used the excellent tools you created for Google Sheets to tap the API and assess ORES quality ratings for the biographies of women journalists our volunteers add to Wikipedia. The ORES ratings, I believe, are being deprecated for something called LiftWing. I’m wondering if you are making, or have ideas about a new set of tools on this new system that I might use to keep our tracking going. Our best bet is to transition to embedding from our Wikipedia system directly. I’ll drop this note in the meeting agenda too.

https://docs.google.com/spreadsheets/d/1wE13YSPN6I-odyo7MuYaUqO5hPuKTWaqtc-dmN3_sfw/edit#gid=1715631735 and here is the backend on how we use the ORES API

We use this tool https://github.com/tomayac/wikipedia-tools-for-google-spreadsheets

1.png (704×1 px, 559 KB)

2.png (408×1 px, 185 KB)

Event Timeline

The script referenced in the Google Sheets App uses the MediaWiki Action API. You'll want to use the revisions property in the query module, and request the oresscores property specifically. E.g.
https://en.wikipedia.org/w/api.php?action=query&format=json&prop=revisions&titles=Darin&formatversion=2&rvprop=ids%7Ctimestamp%7Cflags%7Ccomment%7Cuser%7Coresscores

@AgnesAbah have you managed to resolve the issue?
As Kosta mentioned there isn't anything there related to Lift Wing but with the MediaWiki Action API.

Please re-open if there is still an issue.

@Eganmargaret and i managed to resolve it using Liftwing API in App Script on Googlesheet but I noticed it often gets the response: Exception : Service invoked too many times for one day.
After a few hours I will start getting the response back and after some time the error comes again.
I am accessing the Liftwing API for enwiki-article quality and enwiki-article damaging without authorization.

Find attached a screenshot of the error

image.png (84×220 px, 18 KB)

// Function to fetch article quality prediction from Wikimedia API
/*@customfunction */
function fetchEnwikiArticleQuality(revid) {

var revid = 1184627219; //this is a sample revid gotten from the google sheet i am working on
if (!revid) {

return 'RevId is empty';

}

var cache = CacheService.getScriptCache();
var cacheKey = 'articlequality_' + revid;

// Check if data is cached
var cachedData = cache.get(cacheKey);
if (cachedData != null) {

return cachedData;

}

var url = 'https://api.wikimedia.org/service/lw/inference/v1/models/enwiki-articlequality:predict';
var headers = {

'Content-Type': 'application/json'

};

var data = {

"rev_id": revid

};

try {

var response = UrlFetchApp.fetch(url, {
  'method': 'POST',
  'headers': headers,
  'payload': JSON.stringify(data)
});

var responseData = JSON.parse(response.getContentText());
var articlePrediction = responseData.enwiki.scores[revid].articlequality.score.prediction || 'not available';

// Cache the response for 5 minutes (300 seconds)
cache.put(cacheKey, articlePrediction, 300);

return articlePrediction;

} catch (error) {

console.error('Error fetching data:', error);
return 'Error fetching data';

}
}

Function to fetch damaging prediction from Wikimedia API
/*@customfunction */
function fetchEnwikiDamaging(revid) {
var revid = 1184627219; this is a sample revid gotten from the google sheet i am working on

if (!revid) {

return 'RevId is empty';

}

var cache = CacheService.getScriptCache();
var cacheKey = 'damaging_' + revid;

// Check if data is cached
var cachedData = cache.get(cacheKey);
if (cachedData != null) {

return cachedData;

}

var url = 'https://api.wikimedia.org/service/lw/inference/v1/models/enwiki-damaging:predict';
var headers = {

'Content-Type': 'application/json'

};

var data = {

"rev_id": revid

};

try {

var response = UrlFetchApp.fetch(url, {
  'method': 'POST',
  'headers': headers,
  'payload': JSON.stringify(data)
});

var responseData = JSON.parse(response.getContentText());
var damagingPrediction = responseData.enwiki.scores[revid].damaging.score.prediction || 'not available';

// Cache the response for 5 minutes (300 seconds)
cache.put(cacheKey, damagingPrediction, 300);

return damagingPrediction;

} catch (error) {

console.error('Error fetching data:', error);
return 'Error fetching data';

}
}

I would appreciate a response / guide on how to solve the problem.

Thank you

AgnesAbah added a subscriber: Udehb-WMF.

@Eganmargaret and i managed to resolve it using Liftwing API in App Script on Googlesheet but I noticed it often gets the response: Exception : Service invoked too many times for one day.

It looks like you've hit a rate limit for the service. I am not sure what the rate limit is, cc @achou and @isarantopoulos who may know the answer to that.

@kostajh thanks for your contributions i will be waiting for @achou and @isarantopoulos response

Hello, yes Kosta is right and it seems that you hit the rate limit. Copying from the Wikitech Page these are the limits:

The Lift Wing endpoints have the following rate limits tiers:

50000 requests/hour for every anonymous clients/IP.
100000 requests/hour for every authenticated OAuth2 user (elevated to the internal tier).
200000 requests/hour for every authenticated OAuth2 user from Wikimedia Enterprise (the token needs to be elevated to the wme tier).

@AgnesAbah do you know approximately how many requests you make or you need to make?