Skip to content

403 Forbidden When I Try to pull #240

@erayerdin

Description

@erayerdin

I try to pull the model as such:

import { QueryClient } from "@tanstack/react-query";
import { Ollama } from "ollama";

import Model, { models } from "@/types/model";

type Params = {
  ollama: null | Ollama;
  queryClient: QueryClient;
  tag: string;
};

type Return = {
  abort: () => void;
};

const pullModel = async ({
  ollama,
  queryClient,
  tag,
}: Params): Promise<Return> => {
  console.log("Pulling model...", tag);

  if (ollama === null) {
    throw new Error(
      `Ollama model was not initialized while pulling model ${tag}.`
    );
  }

  const localModel = models.find(({ tag: t }) => t === tag);

  if (localModel === undefined) {
    throw new Error(`Model ${tag} not found in supported models.`);
  }

  const stream = await ollama.pull({ model: tag, stream: true });

  (async () => {
    for await (const { completed, status, total } of stream) {
      if (status === "success") {
        queryClient.setQueryData(["ollama", "model", tag], {
          ...localModel,
          status: { state: "downloaded" },
        } satisfies Model);
      }

      queryClient.setQueryData(["ollama", "model", tag], {
        ...localModel,
        status: {
          progress: (1 / total) * completed,
          state: "downloading",
        },
      } satisfies Model);
    }
  })();

  return { abort: stream.abort };
};

export default pullModel;

...but it errs on runtime saying:

ollama.js?v=6bc093be:631 Uncaught (in promise) ResponseError: Error 403: Forbidden
    at checkOk (ollama.js?v=6bc093be:631:9)
    at async post (ollama.js?v=6bc093be:696:3)
    at async Ollama2.processStreamableRequest (ollama.js?v=6bc093be:814:25)
    at async pullModel (pullModel.ts:52:18)

Version is 0.5.17. Normal ollama pull on terminal works fine. I work on Fedora.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions