mirror of
https://github.com/coalaura/whiskr.git
synced 2025-09-09 17:29:54 +00:00
tags and caching
This commit is contained in:
32
models.go
32
models.go
@@ -4,13 +4,15 @@ import (
|
||||
"context"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/revrost/go-openrouter"
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
SupportedParameters []string `json:"supported_parameters,omitempty"`
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
var ModelMap = make(map[string]*Model)
|
||||
@@ -37,10 +39,10 @@ func LoadModels() ([]*Model, error) {
|
||||
}
|
||||
|
||||
m := &Model{
|
||||
ID: model.ID,
|
||||
Name: name,
|
||||
Description: model.Description,
|
||||
SupportedParameters: model.SupportedParameters,
|
||||
ID: model.ID,
|
||||
Name: name,
|
||||
Description: model.Description,
|
||||
Tags: GetModelTags(model),
|
||||
}
|
||||
|
||||
models[index] = m
|
||||
@@ -50,3 +52,17 @@ func LoadModels() ([]*Model, error) {
|
||||
|
||||
return models, nil
|
||||
}
|
||||
|
||||
func GetModelTags(model openrouter.Model) []string {
|
||||
var tags []string
|
||||
|
||||
for _, parameter := range model.SupportedParameters {
|
||||
if parameter == "reasoning" || parameter == "tools" {
|
||||
tags = append(tags, parameter)
|
||||
}
|
||||
}
|
||||
|
||||
sort.Strings(tags)
|
||||
|
||||
return tags
|
||||
}
|
||||
|
Reference in New Issue
Block a user