Quickstart Deepseek locally

Update: Quickstart Slowstart

Here’s a concise punchlist to set up a new macOS machine with Ollama running DeepSeek on port 8080, exposed via ngrok, with the port change made permanent:


Punchlist for New Machine Setup

  1. Install Ollama bash curl -fsSL https://ollama.com/install.sh | sh
  2. Pull DeepSeek Model bash ollama pull deepseek-r1
  3. Set OLLAMA_HOST Temporarily (Test) bash export OLLAMA_HOST="0.0.0.0:8080"
  4. Start Ollama on Port 8080 bash ollama serve
  5. Test Ollama Locally bash curl http://localhost:8080
  6. Make OLLAMA_HOST Permanent (zsh) bash echo 'export OLLAMA_HOST="0.0.0.0:8080"' >> ~/.zshrc source ~/.zshrcOR for bash (if applicable): bash echo 'export OLLAMA_HOST="0.0.0.0:8080"' >> ~/.bash_profile source ~/.bash_profile
  7. Verify Persistence bash echo $OLLAMA_HOST
  8. Install Ngrok (if not installed) bash brew install ngrok/ngrok/ngrok
  9. Set Ngrok Authtoken (replace YOUR_TOKEN) bash ngrok config add-authtoken YOUR_TOKEN
  10. Start Ngrok Tunnel to 8080 bash ngrok http 8080
  11. Test Ngrok Tunnel (replace with your ngrok URL) bash curl https://your-ngrok-url
  12. Test DeepSeek via Ngrok (replace with your ngrok URL) bash curl https://your-ngrok-url/api/generate -d '{"model": "deepseek-r1", "prompt": "Test from ngrok"}'

Notes

  • Replace YOUR_TOKEN with your ngrok authtoken.
  • Replace your-ngrok-url with the forwarding URL from ngrok (e.g., https://abc123.ngrok.app).
  • Use zsh commands unless echo $SHELL shows /bin/bash, then use bash alternatives.
  • Run commands in order; skip installation steps if tools are already present.

At this point you can talk to Deepseek through Terminal. To create an app interface, you need to basically build a local HTML-engine app (Electron) because using a browser creates too many headaches with local security.

So you can do this. I would just copy and paste the below into your AI of choice and you’ll get all the spelled out how-to steps in better detail.

Steps to Create an Electron App for Ollama/Deepseek

  1. Install Prerequisites:
    • Install Node.js and npm if not already installed.
  2. Create Project Directory:bashCopyEditmkdir deepseek-chat cd deepseek-chat
  3. Initialize Node.js Project:bashCopyEditnpm init -y
  4. Install Electron:bashCopyEditnpm install electron --save-dev
  5. Create Main Application File:
    • Create main.js:
    javascriptCopyEditconst { app, BrowserWindow } = require('electron'); function createWindow() { const win = new BrowserWindow({ width: 800, height: 600, webPreferences: { nodeIntegration: true, contextIsolation: false, }, }); win.loadFile('index.html'); } app.whenReady().then(createWindow);
  6. Create HTML File:
    • Create index.html with a chat interface that interacts with the Deepseek API:
    htmlCopyEdit<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Deepseek Chat</title> <style> /* Add styles here */ </style> </head> <body> <div id="chat"></div> <input type="text" id="input" placeholder="Type your message here..." /> <button id="sendButton">Send</button> <div id="response"></div> <script> /* Add JavaScript for API calls and formatting */ </script> </body> </html>
  7. Set Up API Call:
    • In the <script> section, implement the sendQuery function to send requests to your Ollama/Deepseek server via ngrok:
    javascriptCopyEditconst apiUrl = "https://0eaf-96-239-72-6.ngrok-free.app/api/generate"; async function sendQuery() { // Handle sending input to the API and displaying the response }
  8. Update package.json:
    • Ensure the entry point is set to main.js:
    jsonCopyEdit"main": "main.js",
  9. Add Start Script:
    • Modify the scripts section in package.json to include:
    jsonCopyEdit"scripts": { "start": "electron ." }
  10. Run Your App:bashCopyEditnpm start
  11. Format Output:
    • Improve the readability of responses by adding HTML formatting, CSS classes, and replacing newline characters with <br> tags.
  12. Test and Debug:
    • Use the developer tools in Electron to debug and ensure the application works as expected. Monitor the Ollama server logs for incoming requests.

Final Notes

  • Make sure your Ollama server is running and accessible via the ngrok URL.
  • Adjust the API call in your Electron app to match the expected structure and endpoint of your Deepseek server.

Leave a Reply