ollama / ollama-js

Ollama JavaScript library
https://ollama.ai
MIT License
1.93k stars 134 forks source link

ResponseError: invalid model name , when running any model name in node js #118

Open Aniirudh opened 1 month ago

Aniirudh commented 1 month ago

`import ollama from 'ollama';

async function runChat() { try { // Pull the model first await ollama.pull('llama2');

const response = await ollama.chat({
  model: 'llama2',
  messages: [{ role: 'user', content: 'Why is the sky blue?' }],
});
console.log(response.message.content);

} catch (error) { console.error('Error:', error); } }

runChat(); ` i am getting the below error when running the default code given in the docs, i tried to pull the model first, but even then i am receving the same error, can anyone help with this issue

node index.js

Error: ResponseError: invalid model name at checkOk (file:///C:/Users//Desktop/ollama/node/node_modules/ollama/dist/shared/ollama.7987ad93.mjs:70:9) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async post (file:///C:/Users//Desktop/ollama/node/node_modules/ollama/dist/shared/ollama.7987ad93.mjs:117:3) at async Ollama.processStreamableRequest (file:///C:/Users//Desktop/ollama/node/node_modules/ollama/dist/shared/ollama.7987ad93.mjs:249:22) at async runChat (file:///C:/Users//Desktop/ollama/node/index.js:16:6) { error: 'invalid model name', status_code: 400 }

thinkverse commented 1 month ago

You need to pass in an object to ollama.pull. Like you do for most functions. You can see that in the documentation in the README for pull - https://github.com/ollama/ollama-js?tab=readme-ov-file#pull

await ollama.pull({
  model: "llama2",
});