chat.ts 348 B

1234567891011
  1. import ollama, { Message } from 'ollama'
  2. async function main(): Promise<void> {
  3. const messages: Message[] = [{ role: 'user', content: 'Why is the sky blue?' }]
  4. const stream = await ollama.chat({ model: 'mistral', messages, stream: true })
  5. for await (const part of stream) {
  6. process.stdout.write(part.message.content)
  7. }
  8. }
  9. await main()