ollama / ollama-js

Ollama JavaScript library
https://ollama.com
MIT License
2.12k stars 160 forks source link

TypeError: o[Symbol.iterator] is not a function #33

Open astoilkov opened 9 months ago

astoilkov commented 9 months ago

Running this code:

const response = await ollama.pull({
  model: props.modelName,
  stream: true
})

for await (const data of response) {
  const percent = data.completed / data.total * 100
  setPercent(percent)
}

Produces this error:

image

astoilkov commented 9 months ago

Just saw that the same thing happens without stream: true as well.

da-z commented 9 months ago

I have this error too in Chromium and Safari, but Firefox works fine.

da-z commented 8 months ago

One idea is to split the code in 2 libraries. One for browser, without the push/pull stuff and anything that requires fs (call it ollama-js-browser). With just the chat API, model list. (this is what I did essentially - ripped the chat part of the library and vendored the code in https://github.com/da-z/llamazing)

astoilkov commented 8 months ago

I think Electron should be considered as well. There are both Node and browser APIs.

dahjson commented 8 months ago

I'm having the same issue using this within a web app on Chrome. I'm just using the API directly in the meantime, but would prefer to use this package for simplification.