diff --git a/cmd/cmd.go b/cmd/cmd.go index 7814734a..fb10e53f 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -1050,7 +1050,7 @@ func NewCLI() *cobra.Command { RunE: CreateHandler, } - createCmd.Flags().StringP("file", "f", "Modelfile", "Name of the Modelfile (default \"Modelfile\")") + createCmd.Flags().StringP("file", "f", "Modelfile", "Name of the Modelfile") createCmd.Flags().StringP("quantize", "q", "", "Quantize model to this level (e.g. q4_0)") showCmd := &cobra.Command{ diff --git a/openai/openai.go b/openai/openai.go index 4b335f36..7ce29e9f 100644 --- a/openai/openai.go +++ b/openai/openai.go @@ -107,9 +107,14 @@ func toChatCompletion(id string, r api.ChatResponse) ChatCompletion { Model: r.Model, SystemFingerprint: "fp_ollama", Choices: []Choice{{ - Index: 0, - Message: Message{Role: r.Message.Role, Content: r.Message.Content}, - FinishReason: &r.DoneReason, + Index: 0, + Message: Message{Role: r.Message.Role, Content: r.Message.Content}, + FinishReason: func(reason string) *string { + if len(reason) > 0 { + return &reason + } + return nil + }(r.DoneReason), }}, Usage: Usage{ // TODO: ollama returns 0 for prompt eval if the prompt was cached, but openai returns the actual count @@ -127,13 +132,16 @@ func toChunk(id string, r api.ChatResponse) ChatCompletionChunk { Created: time.Now().Unix(), Model: r.Model, SystemFingerprint: "fp_ollama", - Choices: []ChunkChoice{ - { - Index: 0, - Delta: Message{Role: "assistant", Content: r.Message.Content}, - FinishReason: &r.DoneReason, - }, - }, + Choices: []ChunkChoice{{ + Index: 0, + Delta: Message{Role: "assistant", Content: r.Message.Content}, + FinishReason: func(reason string) *string { + if len(reason) > 0 { + return &reason + } + return nil + }(r.DoneReason), + }}, } } diff --git a/server/envconfig/config_test.go b/server/envconfig/config_test.go index b2760299..bad7c4a7 100644 --- a/server/envconfig/config_test.go +++ b/server/envconfig/config_test.go @@ -1,20 +1,20 @@ package envconfig import ( - "os" "testing" "github.com/stretchr/testify/require" ) func TestConfig(t *testing.T) { - os.Setenv("OLLAMA_DEBUG", "") + Debug = false // Reset whatever was loaded in init() + t.Setenv("OLLAMA_DEBUG", "") LoadConfig() require.False(t, Debug) - os.Setenv("OLLAMA_DEBUG", "false") + t.Setenv("OLLAMA_DEBUG", "false") LoadConfig() require.False(t, Debug) - os.Setenv("OLLAMA_DEBUG", "1") + t.Setenv("OLLAMA_DEBUG", "1") LoadConfig() require.True(t, Debug) } diff --git a/types/model/name.go b/types/model/name.go index b79374c3..f32b2596 100644 --- a/types/model/name.go +++ b/types/model/name.go @@ -291,11 +291,9 @@ func (n Name) Filepath() string { panic("illegal attempt to get filepath of invalid name") } return filepath.Join( - strings.ToLower(filepath.Join( - n.Host, - n.Namespace, - n.Model, - )), + n.Host, + n.Namespace, + n.Model, n.Tag, ) } diff --git a/types/model/name_test.go b/types/model/name_test.go index fb584291..27a8ccf8 100644 --- a/types/model/name_test.go +++ b/types/model/name_test.go @@ -276,9 +276,9 @@ func TestFilepathAllocs(t *testing.T) { allocs := testing.AllocsPerRun(1000, func() { n.Filepath() }) - var allowedAllocs float64 = 3 + var allowedAllocs float64 = 1 if runtime.GOOS == "windows" { - allowedAllocs = 5 + allowedAllocs = 3 } if allocs > allowedAllocs { t.Errorf("allocs = %v; allowed %v", allocs, allowedAllocs)