Added company name to model list

This commit is contained in:
Adrien Bouvais 2024-06-16 12:17:16 +02:00
parent c7ca2bc4a0
commit 5b7c4988d4
3 changed files with 19 additions and 23 deletions

19
Chat.go
View File

@ -753,7 +753,24 @@ func GenerateModelPopoverHTML(refresh bool, c *fiber.Ctx) string {
panic(err) panic(err)
} }
modelInfos := GetAvailableModels(c) var modelInfos []ModelInfo
err = edgeGlobalClient.WithGlobals(map[string]interface{}{"ext::auth::client_token": c.Cookies("jade-edgedb-auth-token")}).Query(edgeCtx, `
SELECT ModelInfo {
modelID,
name,
company : {
name,
icon
}
}
FILTER .modelID != 'none' AND .company.name != 'huggingface' AND .company IN global currentUser.setting.keys.company
ORDER BY .company.name ASC THEN .name ASC
`, &modelInfos)
if err != nil {
fmt.Println("Error getting models")
panic(err)
}
isPremium, isBasic := IsCurrentUserSubscribed(c) isPremium, isBasic := IsCurrentUserSubscribed(c)
out, err := modelPopoverTmpl.Execute(pongo2.Context{ out, err := modelPopoverTmpl.Execute(pongo2.Context{

View File

@ -231,24 +231,3 @@ func Message2RequestMessage(messages []Message, context string) []RequestMessage
return m return m
} }
} }
func GetAvailableModels(c *fiber.Ctx) []ModelInfo {
var models []ModelInfo
err := edgeGlobalClient.WithGlobals(map[string]interface{}{"ext::auth::client_token": c.Cookies("jade-edgedb-auth-token")}).Query(edgeCtx, `
SELECT ModelInfo {
modelID,
name,
company : {
name,
icon
}
}
FILTER .modelID != 'none' AND .company.name != 'huggingface' AND .company IN global currentUser.setting.keys.company
ORDER BY .company.name ASC THEN .name ASC
`, &models)
if err != nil {
fmt.Println("Error getting models")
panic(err)
}
return models
}

View File

@ -48,7 +48,7 @@
<div class="select is-fullwidth is-small mb-3" id="model-id-input"> <div class="select is-fullwidth is-small mb-3" id="model-id-input">
<select name="selectedLLMId"> <select name="selectedLLMId">
{% for modelInfo in ModelInfos %} {% for modelInfo in ModelInfos %}
<option value="{{ modelInfo.ModelID }}">{{ modelInfo.Name }}</option> <option value="{{ modelInfo.ModelID }}">{{ modelInfo.Company.Name }} - {{ modelInfo.Name }}</option>
{% endfor %} {% endfor %}
<option value="{% if IsSub %}custom{% else %}none{% endif %}">Inference Endpoints</option> <option value="{% if IsSub %}custom{% else %}none{% endif %}">Inference Endpoints</option>
</select> </select>