Repository: ollama
Issue: Enhancement Request: Network-Distributed Inference(NDI) and Intuitive Resource Sharing
Labels: feature request

I am proposing an enhancement for the Ollama project that I believe would significantly benefit all users, especially those with an interest in distributed computing and AI.

**Proposed Enhancements:**
1. **Network Distribution Toggle:** I want to implement a toggle option in the system tray menu labeled "Network Distribution." This feature would enable users to opt-in to using network-distributed models for inference tasks. With user consent, when their computer is idle, it would contribute processing power to our network pool.

2. **Preferences Menu:** The "Preferences" option within the tray menu will lead to an intuitive interface. This interface will allow users to configure Ollama settings and select which distributed models they wish to support or use for inference. In the future, it could also include options for contributing to fine-tuning processes through distributed computing efforts.

3. **User Experience & Accessibility:** The Preferences interface will be designed to be intuitive for non-technical users, ensuring they can easily configure settings and understand which models they are contributing to and the benefits of doing so.

**Visual Example:**

<img width="212" alt="Screenshot 2023-11-18 at 1 08 47 AM" src="https://github.com/jmorganca/ollama/assets/2671466/5e374434-2f9c-4837-96cd-af3cedb83a66">

In the image, the current system tray menu includes "Network Distribution" and "Preferences" options.

**Current Progress:**

So far, the modifications have been focused on the user interface, without any backend changes. This has been done to demonstrate how the changes are unintrusive to the current UI. Here's a summary of the changes made to `app/src/index.ts`:

- Implemented `updateTrayTooltip` to dynamically update the tray tooltip reflecting the network distribution status.
- Added `toggleNetworkDistribution` to handle the toggling of network distribution feature.
- Updated `updateTray` to build a tray menu that now includes a "Preferences" option and a "Network Distribution" toggle.

**Code Snippet:**
```typescript
// ... existing imports and code

function updateTrayTooltip() {
  let tooltipText = 'Ollama';
  if (isNetworkDistributed) {
    tooltipText += ' - Network Distribution is ON';
  } else {
    tooltipText += ' - Network Distribution is OFF';
  }
  if (tray) {
    tray.setToolTip(tooltipText);
  }
}

let isNetworkDistributed: boolean = store.get('isNetworkDistributed', false) as boolean;

function toggleNetworkDistribution() {
  isNetworkDistributed = !isNetworkDistributed;
  // store.set('isNetworkDistributed', isNetworkDistributed);
  // updateTray(); // Call this to update the tray icon and menu
  // Call updateTrayTooltip() whenever you need to update the tooltip,
  // for example, after toggling the network distribution state:
  updateTrayTooltip(); // Update the tooltip text
  // Additional code to handle the activation/deactivation of network resource pooling
  if (isNetworkDistributed) {
    // Code to handle when network distribution is activated
    console.log('Network distribution is enabled.');
  } else {
    // Code to handle when network distribution is deactivated
    console.log('Network distribution is disabled.');
  }
}

// Add the network distribution toggle to your menu template
const networkDistributionToggle: MenuItemConstructorOptions = {
  label: 'Network Distribution',
  type: 'checkbox',
  checked: isNetworkDistributed,
  click: toggleNetworkDistribution,
};


function updateTray() {
  const updateItems: MenuItemConstructorOptions[] = [
    { label: 'An update is available', enabled: false },
    {
      label: 'Restart to update',
      click: () => autoUpdater.quitAndInstall(),
    },
    { type: 'separator' },
  ]

  const menu = Menu.buildFromTemplate([
    ...(updateAvailable ? updateItems : []),
    networkDistributionToggle, // Include the network distribution toggle here
    { role: 'quit', label: 'Preferences', accelerator: 'Command+,', click: () => firstRunWindow() },
    { role: 'quit', label: 'Quit Ollama', accelerator: 'Command+Q' },
  ])

  if (!tray) {
    tray = new Tray(trayIconPath())
  }

  tray.setToolTip(updateAvailable ? 'An update is available' : 'Ollama')
  tray.setContextMenu(menu)
  tray.setImage(trayIconPath())

  nativeTheme.off('updated', updateTrayIcon)
  nativeTheme.on('updated', updateTrayIcon)
}

// ... the rest of the code
```

**Why This Matters:**

Implementing these features would advance Ollama's capabilities and encourage greater community involvement in AI development. It supports a vision of making AI more accessible and collaborative.

I would greatly appreciate the community's support, feedback, and contributions to realize this vision. Your expertise in Electron, UI/UX design, or network programming would be invaluable.

Thank you for considering this enhancement. I am eager to discuss further and work together on making this a reality for Ollama.