Skip to content

Commit e3bd14c

Browse files
author
James Brundage
committed
feat: Get-Ollama -Seed and -Temperature ( Fixes #3 )
1 parent 9fa4653 commit e3bd14c

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

Commands/Get-Ollama.ps1

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,20 @@ function Get-Ollama {
7979
[Parameter(ValueFromPipelineByPropertyName,ParameterSetName='/embeddings')]
8080
[Alias('Options')]
8181
[PSObject]
82-
$Option,
82+
$Option = [Ordered]@{},
83+
84+
[Parameter(ValueFromPipelineByPropertyName,ParameterSetName='/generate')]
85+
[Parameter(ValueFromPipelineByPropertyName,ParameterSetName='/chat')]
86+
[Parameter(ValueFromPipelineByPropertyName,ParameterSetName='/embeddings')]
87+
[int]
88+
$Seed,
89+
90+
[Parameter(ValueFromPipelineByPropertyName,ParameterSetName='/generate')]
91+
[Parameter(ValueFromPipelineByPropertyName,ParameterSetName='/chat')]
92+
[Parameter(ValueFromPipelineByPropertyName,ParameterSetName='/embeddings')]
93+
[int]
94+
$Temperature,
95+
8396

8497
# When creating a new model, this is the name of the base model
8598
[Parameter(ValueFromPipelineByPropertyName,ParameterSetName='/create')]
@@ -373,8 +386,24 @@ function Get-Ollama {
373386
if ($MyInvocation.InvocationName -ne $MyInvocation.MyCommand.Name) {
374387
$argumentList = @("run", $MyInvocation.InvocationName) + $argumentList
375388
}
389+
if ($Format -and -not ($ArgumentList -contains '--format')) {
390+
$argumentList += @("--format", $Format)
391+
}
376392
& $ollamaCli @ArgumentList
377393
}
394+
{
395+
$Seed -or $Temperature
396+
} {
397+
if ($Seed) {
398+
# If we have a seed, set the appropriate option
399+
$Option['seed'] = $Seed
400+
}
401+
402+
if ($Temperature) {
403+
# If we have a temperature, set the appropriate option
404+
$Option['temperature'] = $Temperature
405+
}
406+
}
378407
# version is the easiest parameter set
379408
"/version" {
380409
# If `-WhatIf` was passed, return the splat.
@@ -461,7 +490,7 @@ function Get-Ollama {
461490
if ($NoStream) {
462491
# say so now.
463492
$invokeSplat.Body.stream = $false
464-
}
493+
}
465494

466495
# If we have any additional options
467496
if ($Option) {

0 commit comments

Comments
 (0)