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

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

Open
Aniirudh opened this issue Jul 23, 2024 · 1 comment

Comments

@Aniirudh
Copy link

`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
Copy link
Contributor

thinkverse commented Jul 23, 2024

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",
});

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

No branches or pull requests

2 participants