coleam00 / bolt.new-any-llm

Prompt, run, edit, and deploy full-stack web applications using any LLM you want!
https://bolt.new
MIT License
619 stars 376 forks source link

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

Closed yunatamos closed 2 days ago

yunatamos commented 3 days ago

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

venomtoxin1 commented 3 days ago

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\miniflare@3.20240701.0\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\miniflare@3.20240701.0\node_modules\miniflare\dist\src\index.js:3521:16) at async #waitForReady (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm\miniflare@3.20240701.0\node_modules\miniflare\dist\src\index.js:9235:5) at async Miniflare2._getProxyClient (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm\miniflare@3.20240701.0\node_modules\miniflare\dist\src\index.js:9359:5) at async Miniflare2.getBindings (E:\bolt\bolt.new-any-llm-main\node_modules.pnpm\miniflare@3.20240701.0\node_modules\miniflare\dist\src\index.js:9378:25) at async getPlatformProxy (E:\bolt\bolt.new-any-llm-main\nodemodules.pnpm\wrangler@3.63.2@cloudflare+workers-types@4.20240620.0\node_modules\wrangler\wrangler-dist\cli.js:210522:20) at async configureServer (E:\bolt\bolt.new-any-llm-main\nodemodules.pnpm\@remix-run+dev@2.10.0@remix-run+react@2.10.2_react-dom@18.3.1_react@18.3.1react@18.3.1_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/nodemodules/.pnpm/vite@5.3.1@types+node@20.14.9_sass@1.77.6/node_modules/vite/dist/node/chunks/dep-BcXSligG.js:63299:20) at async configResolved (E:\bolt\bolt.new-any-llm-main\nodemodules.pnpm\@remix-run+dev@2.10.0@remix-run+react@2.10.2_react-dom@18.3.1_react@18.3.1react@18.3.1_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/nodemodules/.pnpm/vite@5.3.1@types+node@20.14.9_sass@1.77.6/node_modules/vite/dist/node/chunks/dep-BcXSligG.js:66626:3) at async _createServer (file:///E:/bolt/bolt.new-any-llm-main/nodemodules/.pnpm/vite@5.3.1@types+node@20.14.9_sass@1.77.6/node_modules/vite/dist/node/chunks/dep-BcXSligG.js:62977:18) at async dev (E:\bolt\bolt.new-any-llm-main\nodemodules.pnpm\@remix-run+dev@2.10.0@remix-run+react@2.10.2_react-dom@18.3.1_react@18.3.1react@18.3.1_typ_qwyxqdhnwp3srgtibfrlais3ge\node_modules\@remix-run\dev\dist\vite\dev.js:39:16) at async Object.viteDev (E:\bolt\bolt.new-any-llm-main\nodemodules.pnpm\@remix-run+dev@2.10.0@remix-run+react@2.10.2_react-dom@18.3.1_react@18.3.1__react@18.3.1_typ_qwyxqdhnwp3srgtibfrlais3ge\node_modules\@remix-run\dev\dist\cli\commands.js:220:3) at async Object.run (E:\bolt\bolt.new-any-llm-main\nodemodules.pnpm\@remix-run+dev@2.10.0@remix-run+react@2.10.2_react-dom@18.3.1_react@18.3.1react@18.3.1_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 commented 2 days ago

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

chip902 commented 2 days ago

@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 commented 1 day ago

@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