1
Streaming responses from ollama
source link: https://willschenk.com/labnotes/2024/streaming_responses_from_ollama/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
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.
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();
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK