-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be88077
commit 61ef551
Showing
3 changed files
with
46 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
import ollama from 'ollama' | ||
|
||
const response = await ollama.generate({ | ||
model: 'deepseek-coder-v2', | ||
prompt: `def add(`, | ||
suffix: `return c`, | ||
}) | ||
console.log(response.response) | ||
async function main() { | ||
const response = await ollama.generate({ | ||
model: 'deepseek-coder-v2', | ||
prompt: `def add(`, | ||
suffix: `return c`, | ||
}) | ||
console.log(response.response) | ||
} | ||
|
||
main().catch(console.error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import ollama from 'ollama' | ||
|
||
const imagePath = './examples/multimodal/cat.jpg' | ||
const response = await ollama.generate({ | ||
model: 'llava', | ||
prompt: 'describe this image:', | ||
images: [imagePath], | ||
stream: true, | ||
}) | ||
for await (const part of response) { | ||
process.stdout.write(part.response) | ||
async function main() { | ||
const imagePath = './examples/multimodal/cat.jpg' | ||
const response = await ollama.generate({ | ||
model: 'llava', | ||
prompt: 'describe this image:', | ||
images: [imagePath], | ||
stream: true, | ||
}) | ||
for await (const part of response) { | ||
process.stdout.write(part.response) | ||
} | ||
} | ||
|
||
main().catch(console.error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
import ollama from 'ollama' | ||
|
||
const model = 'llama3.1' | ||
console.log(`downloading ${model}...`) | ||
let currentDigestDone = false | ||
const stream = await ollama.pull({ model: model, stream: true }) | ||
for await (const part of stream) { | ||
if (part.digest) { | ||
let percent = 0 | ||
if (part.completed && part.total) { | ||
percent = Math.round((part.completed / part.total) * 100) | ||
} | ||
process.stdout.clearLine(0) // Clear the current line | ||
process.stdout.cursorTo(0) // Move cursor to the beginning of the line | ||
process.stdout.write(`${part.status} ${percent}%...`) // Write the new text | ||
if (percent === 100 && !currentDigestDone) { | ||
console.log() // Output to a new line | ||
currentDigestDone = true | ||
async function main() { | ||
const model = 'llama3.1' | ||
console.log(`downloading ${model}...`) | ||
let currentDigestDone = false | ||
const stream = await ollama.pull({ model: model, stream: true }) | ||
for await (const part of stream) { | ||
if (part.digest) { | ||
let percent = 0 | ||
if (part.completed && part.total) { | ||
percent = Math.round((part.completed / part.total) * 100) | ||
} | ||
process.stdout.clearLine(0) // Clear the current line | ||
process.stdout.cursorTo(0) // Move cursor to the beginning of the line | ||
process.stdout.write(`${part.status} ${percent}%...`) // Write the new text | ||
if (percent === 100 && !currentDigestDone) { | ||
console.log() // Output to a new line | ||
currentDigestDone = true | ||
} else { | ||
currentDigestDone = false | ||
} | ||
} else { | ||
currentDigestDone = false | ||
console.log(part.status) | ||
} | ||
} else { | ||
console.log(part.status) | ||
} | ||
} | ||
|
||
main().catch(console.error) |