2023-07-07 20:07:10 +00:00
|
|
|
import { redirect } from 'next/navigation'
|
|
|
|
|
|
|
|
export default async function Download() {
|
2023-07-08 20:47:58 +00:00
|
|
|
const res = await fetch('https://api.github.com/repos/jmorganca/ollama/releases', { next: { revalidate: 60 } })
|
|
|
|
const data = await res.json()
|
|
|
|
|
|
|
|
if (data.length === 0) {
|
|
|
|
return new Response('not found', { status: 404 })
|
|
|
|
}
|
|
|
|
|
|
|
|
const latest = data[0]
|
|
|
|
const assets = latest.assets || []
|
|
|
|
|
|
|
|
if (assets.length === 0) {
|
|
|
|
return new Response('not found', { status: 404 })
|
|
|
|
}
|
2023-07-07 20:07:10 +00:00
|
|
|
|
|
|
|
// todo: get the correct asset for the current arch/os
|
2023-07-08 20:47:58 +00:00
|
|
|
const asset = assets.find(
|
|
|
|
(a: any) => a.name.toLowerCase().includes('darwin') && a.name.toLowerCase().includes('.zip')
|
|
|
|
)
|
|
|
|
|
|
|
|
if (!asset) {
|
|
|
|
return new Response('not found', { status: 404 })
|
|
|
|
}
|
2023-07-07 20:07:10 +00:00
|
|
|
|
|
|
|
if (asset) {
|
|
|
|
redirect(asset.browser_download_url)
|
|
|
|
}
|
|
|
|
|
|
|
|
return null
|
|
|
|
}
|