Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions gollm/ollama.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ const (
)

type OllamaClient struct {
client *api.Client
client *api.Client
defaultModel string
}

type OllamaChat struct {
Expand All @@ -58,10 +59,20 @@ var _ Client = &OllamaClient{}
func NewOllamaClient(ctx context.Context, opts ClientOptions) (*OllamaClient, error) {
// Create custom HTTP client with SSL verification option from client options
httpClient := createCustomHTTPClient(opts.SkipVerifySSL)
client := api.NewClient(envconfig.Host(), httpClient)

ollamaURL := envconfig.Host()
if opts.URL != nil && opts.URL.Host != "" {
ollamaURL.Host = opts.URL.Host
}
client := api.NewClient(ollamaURL, httpClient)

defaultModel := defaultOllamaModel
if opts.URL != nil {
defaultModel = opts.URL.Query().Get("model")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm...we should only override the defaultModel if the url has model query parameter.. .right ? or am I missing something.

}
return &OllamaClient{
client: client,
client: client,
defaultModel: defaultModel,
}, nil
}

Expand Down Expand Up @@ -110,6 +121,9 @@ func (c *OllamaClient) SetResponseSchema(schema *Schema) error {
}

func (c *OllamaClient) StartChat(systemPrompt, model string) Chat {
if model == "" {
model = c.defaultModel
}
return &OllamaChat{
client: c.client,
model: model,
Expand Down
Loading