Skip to content

Commit

Permalink
Fix error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaroran committed Jan 6, 2024
1 parent 8eccda0 commit f638866
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/ts/process/embedding/transformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,20 @@ async function initTransformers(){
await tfCache.put(url, response)
},
match: async (url:URL|string) => {
console.log('match', url)
if(typeof url === 'string'){
if(url.startsWith('/tf/Xenova/')){
const newURL = 'https://sv.risuai.xyz/transformers/' + url.substring(11)
const v = await tfCache.match(newURL)
if(v){
return v
try {
const newURL = 'https://sv.risuai.xyz/transformers/' + url.substring(11)
const v = await tfCache.match(newURL)
if(v){
return v
}
const response = await fetch(newURL)
await tfCache.put(newURL, response.clone())
return response
} catch (error) {
return await tfCache.match(url)
}
const response = await fetch(newURL)
await tfCache.put(newURL, response.clone())
return response
}
if(Object.keys(tfMap).includes(url)){
const assetId = tfMap[url]
Expand Down

0 comments on commit f638866

Please sign in to comment.