reorproject / reor

Private & local AI personal knowledge management app.
https://reorproject.org
GNU Affero General Public License v3.0
6.78k stars 410 forks source link

Windows install can't download Ollama #318

Open zpar-ky opened 1 month ago

zpar-ky commented 1 month ago

Describe the bug downloadOllama.js windows absolute url 404's.

To Reproduce

I don't expect the following to work either, but here's what I get when trying to add a local llm:

llama3:latest download failed: Error: Error invoking remote method 'pull-ollama-model': TypeError: Cannot read properties of undefined (reading 'pull') 
Stack Trace: Error: Error invoking remote method 'pull-ollama-model': TypeError: Cannot read properties of undefined (reading 'pull')

cursory investigation leads me to the downloadOllama script and it looks for a exe but ollama switched to serving zips at some point for windows.

I downloaded the zip manually and tossed the contents in resources/binaries and things appear to be working. I renamed the exe to ollama-windows-amd64.exe.

Desktop (please complete the following information):

greptile-apps[bot] commented 1 month ago

To resolve the issue with downloading Ollama on Windows, update the downloadOllama.js script to handle the new zip format for Windows binaries. Here are the specific steps:

  1. Modify the binariesInfo object in scripts/downloadOllama.js to point to the zip file:

    win32: {
    url: "https://github.com/ollama/ollama/releases/download/v0.1.48/ollama-windows-amd64.zip",
    path: "../binaries/win32/ollama-windows-amd64.zip",
    },
  2. Update the downloadIfMissing function to extract the zip file after downloading:

    
    const unzip = require('unzipper');

function downloadIfMissing(platformKey) { const info = binariesInfo[platformKey]; const filePath = path.join(__dirname, info.path); ensureDirectoryExistence(filePath);

fs.access(filePath, fs.constants.F_OK, (err) => { if (err) { console.log(Downloading ${platformKey} Ollama binary...); const request = https.get(info.url, (response) => { if (response.statusCode === 200) { const file = fs.createWriteStream(filePath); response.pipe(file); file.on('finish', () => { file.close(async () => { console.log(Downloaded ${platformKey} Ollama binary.); if (platformKey === 'win32') { await fs.createReadStream(filePath).pipe(unzip.Extract({ path: path.dirname(filePath) })); fs.unlinkSync(filePath); // Remove the zip file after extraction } else { setExecutable(filePath); } }); }); } else if (response.statusCode === 302 || response.statusCode === 301) { console.log(Redirection to ${response.headers.location}); binariesInfo[platformKey].url = response.headers.location; downloadIfMissing(platformKey); } else { console.error(Failed to download ${platformKey} binary. Status code: ${response.statusCode}); } }); request.on('error', (error) => { console.error(Error downloading ${platformKey} binary: ${error.message}); }); } else { console.log(${platformKey} Ollama binary already exists.); if (platformKey !== 'win32') { setExecutable(filePath); } } }); }


3. Ensure the `OllamaService` in `electron/main/llm/models/Ollama.ts` correctly references the extracted executable path for Windows:
```javascript
case 'win32':
  exeName = 'ollama-windows-amd64.exe';
  exeDir = app.isPackaged
    ? path.join(process.resourcesPath, 'binaries')
    : path.join(app.getAppPath(), 'binaries', 'win32');
  break;

These changes should address the issue with downloading and extracting the Ollama binary on Windows.

References

/scripts/downloadOllama.js /electron/main/llm/models/Ollama.ts /electron/main/index.ts

#### About Greptile This response provides a starting point for your research, not a precise solution. Help us improve! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. [Ask Greptile](https://app.greptile.com/chat/github/reorproject/reor/main) · [Edit Issue Bot Settings](https://app.greptile.com/apps/github)
zpar-ky commented 1 month ago

Is that an AI written response or a known issue at the moment lol

weilirs commented 1 month ago

It's an AI. I am not using Windows, sorry I can't help you with that...