Conversation
jmorganca
approved these changes
Nov 12, 2025
BruceMacD
reviewed
Nov 12, 2025
Member
There was a problem hiding this comment.
I think we can remove the logprobs-generate.ts example since the code is largely the same as chat.
| images?: Uint8Array[] | string[] | ||
| keep_alive?: string | number // a number (seconds) or a string with a duration unit suffix ("300ms", "1.5h", "2h45m", etc) | ||
| think?: boolean | 'high' | 'medium' | 'low' | ||
| logprobs?: boolean |
Member
There was a problem hiding this comment.
We should add these fields in the README also
Member
Author
There was a problem hiding this comment.
good callout! will add
BruceMacD
reviewed
Nov 12, 2025
examples/logprobs/logprobs-chat.ts
Outdated
Comment on lines
+1
to
+11
| import { Ollama } from 'ollama'; | ||
|
|
||
| function printLogprobs(entries: Array<{ token: string; logprob: number; top_logprobs?: typeof entries }>, label: string) { | ||
| console.log(`\n${label}:`) | ||
| for (const entry of entries) { | ||
| console.log(` token=${entry.token.padEnd(12)} logprob=${entry.logprob.toFixed(3)}`) | ||
| for (const alt of entry.top_logprobs ?? []) { | ||
| console.log(` alt -> ${alt.token.padEnd(12)} (${alt.logprob.toFixed(3)})`) | ||
| } | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
Suggested change
| import { Ollama } from 'ollama'; | |
| function printLogprobs(entries: Array<{ token: string; logprob: number; top_logprobs?: typeof entries }>, label: string) { | |
| console.log(`\n${label}:`) | |
| for (const entry of entries) { | |
| console.log(` token=${entry.token.padEnd(12)} logprob=${entry.logprob.toFixed(3)}`) | |
| for (const alt of entry.top_logprobs ?? []) { | |
| console.log(` alt -> ${alt.token.padEnd(12)} (${alt.logprob.toFixed(3)})`) | |
| } | |
| } | |
| } | |
| import { Ollama, type Logprob } from 'ollama'; | |
| function printLogprobs(entries: Logprob[], label: string) { | |
| console.log(`\n${label}:`) | |
| for (const entry of entries) { | |
| console.log(` token=${entry.token.padEnd(12)} logprob=${entry.logprob.toFixed(3)}`) | |
| for (const alt of entry.top_logprobs ?? []) { | |
| console.log(` alt -> ${alt.token.padEnd(12)} (${alt.logprob.toFixed(3)})`) | |
| } | |
| } | |
| } |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds JS SDK support for: ollama/ollama#12899