Skip to content

Commit

Permalink
feat: add url validation
Browse files Browse the repository at this point in the history
  • Loading branch information
RoseSecurity committed Nov 15, 2024
1 parent afc5164 commit 18025d0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/utils/list_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"net/url"
)

type Model struct {
Expand All @@ -12,6 +13,10 @@ type Model struct {

// ListModels lists available models from Ollama
func ListModels(addr string) ([]string, error) {
if _, err := url.Parse(addr); err != nil {
return nil, fmt.Errorf("invalid address provided: %v", err)
}

resp, err := http.Get(fmt.Sprintf("%s/api/tags", addr))
if err != nil {
return nil, fmt.Errorf("error fetching models from Ollama: %v", err)
Expand Down

0 comments on commit 18025d0

Please sign in to comment.