Compare commits
2 Commits
brucemacd/
...
brucemacd/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f8aac9cd3 | ||
|
|
2b82c5a8a1 |
@@ -156,7 +156,7 @@ PARAMETER <parameter> <parametervalue>
|
||||
| seed | Sets the random number seed to use for generation. Setting this to a specific number will make the model generate the same text for the same prompt. (Default: 0) | int | seed 42 |
|
||||
| stop | Sets the stop sequences to use. When this pattern is encountered the LLM will stop generating text and return. Multiple stop patterns may be set by specifying multiple separate `stop` parameters in a modelfile. | string | stop "AI assistant:" |
|
||||
| tfs_z | Tail free sampling is used to reduce the impact of less probable tokens from the output. A higher value (e.g., 2.0) will reduce the impact more, while a value of 1.0 disables this setting. (default: 1) | float | tfs_z 1 |
|
||||
| num_predict | Maximum number of tokens to predict when generating text. (Default: 128, -1 = infinite generation, -2 = fill context) | int | num_predict 42 |
|
||||
| num_predict | Maximum number of tokens to predict when generating text. (Default: -1, infinite generation) | int | num_predict 42 |
|
||||
| top_k | Reduces the probability of generating nonsense. A higher value (e.g. 100) will give more diverse answers, while a lower value (e.g. 10) will be more conservative. (Default: 40) | int | top_k 40 |
|
||||
| top_p | Works together with top-k. A higher value (e.g., 0.95) will lead to more diverse text, while a lower value (e.g., 0.5) will generate more focused and conservative text. (Default: 0.9) | float | top_p 0.9 |
|
||||
| min_p | Alternative to the top_p, and aims to ensure a balance of quality and variety. The parameter *p* represents the minimum probability for a token to be considered, relative to the probability of the most likely token. For example, with *p*=0.05 and the most likely token having a probability of 0.9, logits with a value less than 0.045 are filtered out. (Default: 0.0) | float | min_p 0.05 |
|
||||
|
||||
@@ -1,21 +1,35 @@
|
||||
import * as fs from 'fs'
|
||||
import { exec as cbExec } from 'child_process'
|
||||
import { spawn } from 'child_process'
|
||||
import * as path from 'path'
|
||||
import { promisify } from 'util'
|
||||
|
||||
const app = process && process.type === 'renderer' ? require('@electron/remote').app : require('electron').app
|
||||
const ollama = app.isPackaged ? path.join(process.resourcesPath, 'ollama') : path.resolve(process.cwd(), '..', 'ollama')
|
||||
const exec = promisify(cbExec)
|
||||
const symlinkPath = '/usr/local/bin/ollama'
|
||||
|
||||
export function installed() {
|
||||
export function installed(): boolean {
|
||||
return fs.existsSync(symlinkPath) && fs.readlinkSync(symlinkPath) === ollama
|
||||
}
|
||||
|
||||
export async function install() {
|
||||
const command = `do shell script "mkdir -p ${path.dirname(
|
||||
symlinkPath
|
||||
)} && ln -F -s \\"${ollama}\\" \\"${symlinkPath}\\"" with administrator privileges`
|
||||
|
||||
await exec(`osascript -e '${command}'`)
|
||||
function validPath(targetPath: string): boolean {
|
||||
const normalized = path.normalize(targetPath)
|
||||
return !(/[;&|`$(){}[\]<>]/.test(normalized) || normalized.includes('..'))
|
||||
}
|
||||
|
||||
export async function install(): Promise<void> {
|
||||
if (!validPath(ollama) || !validPath(symlinkPath)) {
|
||||
throw new Error('Invalid path format')
|
||||
}
|
||||
|
||||
await fs.promises.mkdir(path.dirname(symlinkPath), { recursive: true })
|
||||
.catch(err => err.code === 'EEXIST' ? null : Promise.reject(err))
|
||||
|
||||
const process = spawn('osascript', [
|
||||
'-e',
|
||||
`do shell script "ln -F -s '${path.normalize(ollama)}' '${path.normalize(symlinkPath)}'" with administrator privileges`
|
||||
])
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
process.on('error', reject)
|
||||
process.on('close', code => code === 0 ? resolve() : reject(new Error(`Failed with code ${code}`)))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -802,12 +802,6 @@ func PushModel(ctx context.Context, name string, regOpts *registryOptions, fn fu
|
||||
if mp.ProtocolScheme == "http" && !regOpts.Insecure {
|
||||
return errors.New("insecure protocol http")
|
||||
}
|
||||
if mp.Namespace != strings.ToLower(mp.Namespace) {
|
||||
return fmt.Errorf("namespace must be lowercase, but is %s", mp.Namespace)
|
||||
}
|
||||
if mp.Repository != strings.ToLower(mp.Repository) {
|
||||
return fmt.Errorf("model name must be lowercase, but is %s", mp.Repository)
|
||||
}
|
||||
|
||||
manifest, _, err := GetManifest(mp)
|
||||
if err != nil {
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/ollama/ollama/api"
|
||||
)
|
||||
|
||||
func TestPushModel(t *testing.T) {
|
||||
noOpProgress := func(resp api.ProgressResponse) {}
|
||||
|
||||
tests := []struct {
|
||||
modelStr string
|
||||
regOpts *registryOptions
|
||||
wantErr string
|
||||
}{
|
||||
{
|
||||
modelStr: "http://example.com/namespace/repo:tag",
|
||||
regOpts: ®istryOptions{Insecure: false},
|
||||
wantErr: "insecure protocol http",
|
||||
},
|
||||
{
|
||||
modelStr: "docker://Example/repo:tag",
|
||||
regOpts: ®istryOptions{},
|
||||
wantErr: "namespace must be lowercase, but is Example",
|
||||
},
|
||||
{
|
||||
modelStr: "docker://example/Repo:tag",
|
||||
regOpts: ®istryOptions{},
|
||||
wantErr: "model name must be lowercase, but is Repo",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.modelStr, func(t *testing.T) {
|
||||
err := PushModel(context.Background(), tt.modelStr, tt.regOpts, noOpProgress)
|
||||
|
||||
if tt.wantErr != "" {
|
||||
if err == nil {
|
||||
t.Errorf("PushModel() error = %v, wantErr %v", err, tt.wantErr)
|
||||
} else if !strings.Contains(err.Error(), tt.wantErr) {
|
||||
t.Errorf("PushModel() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
return
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user