package llm

import (
	"encoding/json"
	"io"
	"net/http"
)

type ollamaListModels struct {
	Models []ollamaModel
}

type ollamaModel struct {
	Model string
} 

func listOllamaModels(url string) ([]string, error) {
 	res, err := http.Get(url+"/api/tags")
 	if err != nil {
		return nil, err
	}
	resBody, err := io.ReadAll(res.Body)
	if err != nil {
		return nil, err
	}
	var m ollamaListModels
	err = json.Unmarshal(resBody, &m)
	if err != nil {
		return nil, err
	}

	models := make([]string, len(m.Models))
	for i, m := range m.Models {
		models[i] = m.Model
	}
	return models, nil
 }


