Streaming responses from ollama

really any fetch thing

Published April 10, 2024

javascript, ollama
Contents

I'm still learning modern javascript after all, so here's a little bit to print out the responses from a fetch request as they come in.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
  import ollama from 'ollama/browser'

  async function doCall() {
      console.log( "Starting" )

      const response = await ollama.generate({
          model: 'gemma:7b',
          prompt: 'why is the sky blue?  why is water wet?',
          stream: true,
      })
      for await (const part of response) {
          console.log(part)
      }

      console.log( "done" );
  }

  doCall();

Previously

Image upload with node storing on a seperate directory why do anything so fancy as S3

2024-04-04

Next

Readability and JSDOM took me a while to get this little code

2024-04-11

labnotes

Previously

Image upload with node storing on a seperate directory why do anything so fancy as S3

2024-04-04

Next

Readability and JSDOM took me a while to get this little code

2024-04-11