Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let the ollama models be auto generated from ollama api #5

Merged
merged 2 commits into from
Oct 19, 2024

Conversation

yunatamos
Copy link

with the current implementation user doesnt select custom models so I made it possible to have user select available models

@venomtoxin1
Copy link

venomtoxin1 commented Oct 18, 2024

I have nodejs installed v20.18.0 and pnpm 9.12.2.
Also chrome canary installed.
I get this when pnpm run dev :

bolt@ dev E:\bolt\bolt.new-any-llm-main
remix vite:dev

*** Received structured exception #0xc0000005: access violation; stack: 7ffc0cae301f 7ff676e0337b 7ff676e03443 7ff676df74bc 7ff676df7467 7ff676677d5e 7ff67667806f 7ff675561706 7ff6755614ea 7ff6767ef97f 7ff6767f6b36 7ff6767efe9c 7ff6767f6b36 7ff6767ed80c 7ff675551551 7ff677ed8bff 7ffc1a99257c 7ffc1c10af07
MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.
at #assembleAndUpdateConfig (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm\[email protected]\node_modules\miniflare\dist\src\index.js:9178:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Mutex.runWith (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm\[email protected]\node_modules\miniflare\dist\src\index.js:3521:16)
at async #waitForReady (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm\[email protected]\node_modules\miniflare\dist\src\index.js:9235:5)
at async Miniflare2.getProxyClient (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm\[email protected]\node_modules\miniflare\dist\src\index.js:9359:5)
at async Miniflare2.getBindings (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm\[email protected]\node_modules\miniflare\dist\src\index.js:9378:25)
at async getPlatformProxy (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm\[email protected]
@cloudflare[email protected]\node_modules\wrangler\wrangler-dist\cli.js:210522:20)
at async configureServer (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm@remix-run+dev@2.10.0_@remix-run[email protected][email protected]_react@[email protected]_typ_qwyxqdhnwp3srgtibfrlais3ge\node_modules@remix-run\dev\dist\vite\cloudflare-proxy-plugin.js:55:11)
at async createServer (file:///E:/bolt/bolt.new-any-llm-main/node_modules/.pnpm/[email protected]@types[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BcXSligG.js:63299:20)
at async configResolved (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm@remix-run+dev@2.10.0_@remix-run[email protected][email protected]_react@[email protected]_typ_qwyxqdhnwp3srgtibfrlais3ge\node_modules@remix-run\dev\dist\vite\plugin.js:750:27)
at async Promise.all (index 3)
at async resolveConfig (file:///E:/bolt/bolt.new-any-llm-main/node_modules/.pnpm/vite@5.3.1_@types[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BcXSligG.js:66626:3)
at async createServer (file:///E:/bolt/bolt.new-any-llm-main/node_modules/.pnpm/[email protected]@types[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BcXSligG.js:62977:18)
at async dev (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm@remix-run+dev@2.10.0_@remix-run[email protected][email protected]_react@[email protected]_typ_qwyxqdhnwp3srgtibfrlais3ge\node_modules@remix-run\dev\dist\vite\dev.js:39:16)
at async Object.viteDev (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm@remix-run+dev@2.10.0_@remix-run[email protected][email protected]_react@[email protected]_typ_qwyxqdhnwp3srgtibfrlais3ge\node_modules@remix-run\dev\dist\cli\commands.js:220:3)
at async Object.run (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm@remix-run+dev@2.10.0_@remix-run[email protected][email protected]_react@[email protected]_typ_qwyxqdhnwp3srgtibfrlais3ge\node_modules@remix-run\dev\dist\cli\run.js:271:7) {
code: 'ERR_RUNTIME_FAILURE',
cause: undefined
}
 ELIFECYCLE  Command failed with exit code 1.

@coleam00 coleam00 merged commit fc6356c into stackblitz-labs:main Oct 19, 2024
@coleam00
Copy link
Collaborator

@yunatamos This is a much needed addition so people aren't selecting Ollama models they haven't pulled yet - thank you!!

@chip902
Copy link

chip902 commented Oct 20, 2024

@coleam00 @yunatamos is there anything special we need to do in order to get the auto-poll of Ollama models to work if I want to access Bolt over my own network (i.e. not localhost)? I looked at the files changed, nothing seems out of the ordinary, but I for sure am getting a CORS error.

Google Chrome Canary - Bolt - 2024-10-19 at 22 54 30@2x

I tried making the change to vite.config.ts below but it still doesn't work.

import { cloudflareDevProxyVitePlugin as remixCloudflareDevProxy, vitePlugin as remixVitePlugin } from '@remix-run/dev';
import UnoCSS from 'unocss/vite';
import { defineConfig, type ViteDevServer } from 'vite';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import { optimizeCssModules } from 'vite-plugin-optimize-css-modules';
import tsconfigPaths from 'vite-tsconfig-paths';

export default defineConfig((config) => {
  return {
    build: {
      target: 'esnext',
    },
    server: {
      proxy: {
        '/api': {
          target: 'http://localhost:11434',
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/api/, ''),
        }
      },
      headers: {
        "access-control-allow-origin": "*"
      }
    },
    plugins: [
      nodePolyfills({
        include: ['path', 'buffer'],
      }),
      config.mode !== 'test' && remixCloudflareDevProxy(),
      remixVitePlugin({
        future: {
          v3_fetcherPersist: true,
          v3_relativeSplatPath: true,
          v3_throwAbortReason: true,
        },
      }),
      UnoCSS(),
      tsconfigPaths(),
      chrome129IssuePlugin(),
      config.mode === 'production' && optimizeCssModules({ apply: 'build' }),
    ],
  };
});

function chrome129IssuePlugin() {
  return {
    name: 'chrome129IssuePlugin',
    configureServer(server: ViteDevServer) {
      server.middlewares.use((req, res, next) => {
        const raw = req.headers['user-agent']?.match(/Chrom(e|ium)\/([0-9]+)\./);

        if (raw) {
          const version = parseInt(raw[2], 10);

          if (version === 129) {
            res.setHeader('content-type', 'text/html');
            res.end(
              '<body><h1>Please use Chrome Canary for testing.</h1><p>Chrome 129 has an issue with JavaScript modules & Vite local development, see <a href="https://github.com/stackblitz/bolt.new/issues/86#issuecomment-2395519258">for more information.</a></p><p><b>Note:</b> This only impacts <u>local development</u>. `pnpm run build` and `pnpm run start` will work fine in this browser.</p></body>',
            );

            return;
          }
        }

        next();
      });
    },
  };
}

@yunatamos
Copy link
Author

@coleam00 @yunatamos is there anything special we need to do in order to get the auto-poll of Ollama models to work if I want to access Bolt over my own network (i.e. not localhost)? I looked at the files changed, nothing seems out of the ordinary, but I for sure am getting a CORS error.

Google Chrome Canary - Bolt - 2024-10-19 at 22 54 30@2x

I tried making the change to vite.config.ts below but it still doesn't work.

import { cloudflareDevProxyVitePlugin as remixCloudflareDevProxy, vitePlugin as remixVitePlugin } from '@remix-run/dev';
import UnoCSS from 'unocss/vite';
import { defineConfig, type ViteDevServer } from 'vite';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import { optimizeCssModules } from 'vite-plugin-optimize-css-modules';
import tsconfigPaths from 'vite-tsconfig-paths';

export default defineConfig((config) => {
  return {
    build: {
      target: 'esnext',
    },
    server: {
      proxy: {
        '/api': {
          target: 'http://localhost:11434',
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/api/, ''),
        }
      },
      headers: {
        "access-control-allow-origin": "*"
      }
    },
    plugins: [
      nodePolyfills({
        include: ['path', 'buffer'],
      }),
      config.mode !== 'test' && remixCloudflareDevProxy(),
      remixVitePlugin({
        future: {
          v3_fetcherPersist: true,
          v3_relativeSplatPath: true,
          v3_throwAbortReason: true,
        },
      }),
      UnoCSS(),
      tsconfigPaths(),
      chrome129IssuePlugin(),
      config.mode === 'production' && optimizeCssModules({ apply: 'build' }),
    ],
  };
});

function chrome129IssuePlugin() {
  return {
    name: 'chrome129IssuePlugin',
    configureServer(server: ViteDevServer) {
      server.middlewares.use((req, res, next) => {
        const raw = req.headers['user-agent']?.match(/Chrom(e|ium)\/([0-9]+)\./);

        if (raw) {
          const version = parseInt(raw[2], 10);

          if (version === 129) {
            res.setHeader('content-type', 'text/html');
            res.end(
              '<body><h1>Please use Chrome Canary for testing.</h1><p>Chrome 129 has an issue with JavaScript modules & Vite local development, see <a href="https://github.com/stackblitz/bolt.new/issues/86#issuecomment-2395519258">for more information.</a></p><p><b>Note:</b> This only impacts <u>local development</u>. `pnpm run build` and `pnpm run start` will work fine in this browser.</p></body>',
            );

            return;
          }
        }

        next();
      });
    },
  };
}

hi I harcoded the link and its not in env I will try figure it out how to get link updated in .env am new to this had some issues with env varible working in server but not in client I dont know why

async function getOllamaModels(): Promise<ModelInfo[]> {
try {
const response = await fetch(`http://localhost:11434/api/tags`);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, there is a hardcoded ref to localhost instead of using the .env.

@MoNarchEnterprises
Copy link

I have nodejs installed v20.18.0 and pnpm 9.12.2. Also chrome canary installed. I get this when pnpm run dev :

bolt@ dev E:\bolt\bolt.new-any-llm-main
remix vite:dev

*** Received structured exception #0xc0000005: access violation; stack: 7ffc0cae301f 7ff676e0337b 7ff676e03443 7ff676df74bc 7ff676df7467 7ff676677d5e 7ff67667806f 7ff675561706 7ff6755614ea 7ff6767ef97f 7ff6767f6b36 7ff6767efe9c 7ff6767f6b36 7ff6767ed80c 7ff675551551 7ff677ed8bff 7ffc1a99257c 7ffc1c10af07 MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above. at #assembleAndUpdateConfig (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm\[email protected]\node_modules\miniflare\dist\src\index.js:9178:13) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Mutex.runWith (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm\[email protected]\node_modules\miniflare\dist\src\index.js:3521:16) at async #waitForReady (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm\[email protected]\node_modules\miniflare\dist\src\index.js:9235:5) at async Miniflare2.getProxyClient (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm\[email protected]\node_modules\miniflare\dist\src\index.js:9359:5) at async Miniflare2.getBindings (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm\[email protected]\node_modules\miniflare\dist\src\index.js:9378:25) at async getPlatformProxy (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm\[email protected]@cloudflare[email protected]\node_modules\wrangler\wrangler-dist\cli.js:210522:20) at async configureServer (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm@remix-run+dev@2.10.0_@remix-run[email protected][email protected]_react@[email protected]_typ_qwyxqdhnwp3srgtibfrlais3ge\node_modules@remix-run\dev\dist\vite\cloudflare-proxy-plugin.js:55:11) at async createServer (file:///E:/bolt/bolt.new-any-llm-main/node_modules/.pnpm/[email protected]@types[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BcXSligG.js:63299:20) at async configResolved (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm@remix-run+dev@2.10.0_@remix-run[email protected][email protected]_react@[email protected]_typ_qwyxqdhnwp3srgtibfrlais3ge\node_modules@remix-run\dev\dist\vite\plugin.js:750:27) at async Promise.all (index 3) at async resolveConfig (file:///E:/bolt/bolt.new-any-llm-main/node_modules/.pnpm/vite@5.3.1_@types[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BcXSligG.js:66626:3) at async createServer (file:///E:/bolt/bolt.new-any-llm-main/node_modules/.pnpm/[email protected]@types[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BcXSligG.js:62977:18) at async dev (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm@remix-run+dev@2.10.0_@remix-run[email protected][email protected]_react@[email protected]_typ_qwyxqdhnwp3srgtibfrlais3ge\node_modules@remix-run\dev\dist\vite\dev.js:39:16) at async Object.viteDev (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm@remix-run+dev@2.10.0_@remix-run[email protected][email protected]_react@[email protected]_typ_qwyxqdhnwp3srgtibfrlais3ge\node_modules@remix-run\dev\dist\cli\commands.js:220:3) at async Object.run (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm@remix-run+dev@2.10.0_@remix-run[email protected][email protected]_react@[email protected]_typ_qwyxqdhnwp3srgtibfrlais3ge\node_modules@remix-run\dev\dist\cli\run.js:271:7) { code: 'ERR_RUNTIME_FAILURE', cause: undefined }  ELIFECYCLE  Command failed with exit code 1.

I'm having the exact same issue. Was anyone able to get past this and get it to work?

jhillbht pushed a commit to jhillbht/bolt.new-any-llm that referenced this pull request Jan 27, 2025
let the ollama models be auto generated from ollama api
jhillbht pushed a commit to jhillbht/bolt.new-any-llm that referenced this pull request Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants