feat(naming): playlists named by Claude by themselves when it is on
- Keeping a mix, a smart playlist or a suggested smart playlist as a playlist with auto_name gives it the name and the line of description that Claude makes from its songs. The name sent stays the fallback when the provider is off, or Claude fails or declines, so a failure never stops a playlist from being made. - A smart playlist can be made with no name when Claude is on: it names it from the songs the rules give. Without Claude a name is still needed. - GET /naming says whether names are automatic, so the editor does not ask for a name that Claude will make. - The web app always asks for an automatic name and sends the language of the page.
This commit is contained in:
parent
0dddfb741e
commit
0d8fadadf6
9 changed files with 393 additions and 33 deletions
|
|
@ -1085,6 +1085,15 @@ func (c *contract) smartPlaylists(t *testing.T, token string) {
|
|||
// names asks for names with the Claude provider off, so that the local ones answer.
|
||||
func (c *contract) names(t *testing.T, token string) {
|
||||
t.Helper()
|
||||
c.expect(c.call("GET", "/naming", "", nil), 401, "naming status without a token", "unauthorized")
|
||||
if st := c.expect(c.call("GET", "/naming", token, nil), 200, "naming status"); st["auto"] != false {
|
||||
t.Fatalf("naming status = %v, want off", st)
|
||||
}
|
||||
named := c.expect(c.call("POST", "/mixes/genre%3Asynthwave/playlist", token, map[string]any{"name": "Synth mix", "auto_name": true, "lang": "it"}), 201, "keep a mix with an automatic name, Claude off")
|
||||
if named["name"] != "Synth mix" {
|
||||
t.Fatalf("playlist = %v: with Claude off the given name stays", named)
|
||||
}
|
||||
c.expect(c.call("POST", "/smart-playlists", token, map[string]any{"name": "", "rules": map[string]any{}, "lang": "it"}), 400, "a smart playlist with no name and Claude off", "invalid_input")
|
||||
c.expect(c.call("POST", "/mixes/genre%3Asynthwave/suggest-name", "", nil), 401, "a name without a token", "unauthorized")
|
||||
mix := c.expect(c.call("POST", "/mixes/genre%3Asynthwave/suggest-name", token, map[string]any{"lang": "it", "variant": 1}), 200, "a name for a mix")
|
||||
if mix["source"] != "local" || mix["name"] != "Mix Synthwave" {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import (
|
|||
type mixHandlers struct {
|
||||
svc mixService
|
||||
playlists playlistService
|
||||
naming namingService
|
||||
}
|
||||
|
||||
type mixJSON struct {
|
||||
|
|
@ -109,8 +110,10 @@ func (h *mixHandlers) get(c *gin.Context) {
|
|||
}
|
||||
|
||||
type saveMixRequest struct {
|
||||
Name string `json:"name"` // blank: the title of the mix
|
||||
Variant *int `json:"variant"` // absent: the mix of the day
|
||||
Name string `json:"name"` // blank: the title of the mix
|
||||
Variant *int `json:"variant"` // absent: the mix of the day
|
||||
AutoName bool `json:"auto_name"` // Claude names the playlist when it is on, and name is only the fallback
|
||||
Lang string `json:"lang"`
|
||||
}
|
||||
|
||||
// save makes a playlist of the songs of a mix, the ones that variant shows. A save that fails
|
||||
|
|
@ -138,5 +141,6 @@ func (h *mixHandlers) save(c *gin.Context) {
|
|||
if strings.TrimSpace(name) == "" {
|
||||
name = m.Title
|
||||
}
|
||||
keepAsPlaylist(c, h.playlists, user, name, tracks)
|
||||
name, description := automaticName(c, h.naming, req.AutoName, req.Lang, "mix", tracks, "", name)
|
||||
keepAsPlaylist(c, h.playlists, user, name, description, tracks)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/gin-gonic/gin"
|
||||
|
||||
"codeberg.org/squidd/sonda/internal/catalog"
|
||||
"codeberg.org/squidd/sonda/internal/naming"
|
||||
"codeberg.org/squidd/sonda/internal/playlists"
|
||||
)
|
||||
|
||||
|
|
@ -116,3 +117,26 @@ func (h *namingHandlers) smartName(c *gin.Context) {
|
|||
}
|
||||
h.answer(c, "smart", tracks, p.Rules.Summary(), req.Lang)
|
||||
}
|
||||
|
||||
// status says whether names are made by themselves, so that a page does not ask for a name that Claude will make.
|
||||
func (h *namingHandlers) status(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"auto": h.svc.Auto(c.Request.Context())})
|
||||
}
|
||||
|
||||
// automaticName gives the name and the line of description that Claude makes for the songs, when the page asked for it
|
||||
// and the provider is on and answered. Otherwise it gives the name the page chose, with no description: a failure of the
|
||||
// provider never stops a playlist from being made.
|
||||
func automaticName(c *gin.Context, svc namingService, auto bool, lang, kind string, tracks []catalog.Track, hint, fallback string) (name, description string) {
|
||||
if !auto || !svc.Auto(c.Request.Context()) {
|
||||
return fallback, ""
|
||||
}
|
||||
facts, err := svc.FactsOf(c.Request.Context(), kind, tracks, hint)
|
||||
if err != nil {
|
||||
return fallback, ""
|
||||
}
|
||||
s, err := svc.Suggest(c.Request.Context(), facts, lang)
|
||||
if err != nil || s.Source != naming.SourceClaude {
|
||||
return fallback, ""
|
||||
}
|
||||
return s.Name, s.Description
|
||||
}
|
||||
|
|
|
|||
|
|
@ -270,9 +270,9 @@ func (h *playlistHandlers) moveItem(c *gin.Context) {
|
|||
|
||||
// keepAsPlaylist makes a playlist of the user with the songs, in order, and answers with it. A save that
|
||||
// fails half way leaves no playlist behind.
|
||||
func keepAsPlaylist(c *gin.Context, svc playlistService, user int64, name string, tracks []catalog.Track) {
|
||||
func keepAsPlaylist(c *gin.Context, svc playlistService, user int64, name, description string, tracks []catalog.Track) {
|
||||
ctx := c.Request.Context()
|
||||
pl, err := svc.Create(ctx, user, name, "")
|
||||
pl, err := svc.Create(ctx, user, name, description)
|
||||
if err != nil {
|
||||
writePlaylistError(c, err)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import (
|
|||
type smartHandlers struct {
|
||||
svc smartService
|
||||
playlists playlistService
|
||||
naming namingService
|
||||
}
|
||||
|
||||
type smartJSON struct {
|
||||
|
|
@ -63,6 +64,7 @@ func writeSmartError(c *gin.Context, err error) {
|
|||
}
|
||||
|
||||
type createSmartRequest struct {
|
||||
Lang string `json:"lang"` // for a name that Claude makes
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Rules smart.Rules `json:"rules"`
|
||||
|
|
@ -75,9 +77,19 @@ func (h *smartHandlers) create(c *gin.Context) {
|
|||
if !bindJSON(c, &req) {
|
||||
return
|
||||
}
|
||||
p, err := h.svc.Create(c.Request.Context(), currentUserID(c), smart.Input{
|
||||
Name: req.Name, Description: req.Description, Rules: req.Rules, Sort: smart.Sort(req.Sort), Limit: req.Limit,
|
||||
})
|
||||
in := smart.Input{Name: req.Name, Description: req.Description, Rules: req.Rules, Sort: smart.Sort(req.Sort), Limit: req.Limit}
|
||||
if strings.TrimSpace(in.Name) == "" && h.naming.Auto(c.Request.Context()) {
|
||||
// No name, and Claude is on: it names the playlist from the songs the rules give.
|
||||
if tracks, err := h.svc.Preview(c.Request.Context(), currentUserID(c), in, 0); err == nil {
|
||||
if name, desc := automaticName(c, h.naming, true, req.Lang, "smart", tracks, in.Rules.Summary(), ""); name != "" {
|
||||
in.Name = name
|
||||
if strings.TrimSpace(in.Description) == "" {
|
||||
in.Description = desc
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
p, err := h.svc.Create(c.Request.Context(), currentUserID(c), in)
|
||||
if err != nil {
|
||||
writeSmartError(c, err)
|
||||
return
|
||||
|
|
@ -199,8 +211,10 @@ func (h *smartHandlers) preview(c *gin.Context) {
|
|||
}
|
||||
|
||||
type saveSmartRequest struct {
|
||||
Name string `json:"name"` // blank: the name of the smart playlist
|
||||
Variant *int `json:"variant"` // absent: the songs of the day
|
||||
Name string `json:"name"` // blank: the name of the smart playlist
|
||||
Variant *int `json:"variant"` // absent: the songs of the day
|
||||
AutoName bool `json:"auto_name"` // Claude names the playlist when it is on, and name is only the fallback
|
||||
Lang string `json:"lang"`
|
||||
}
|
||||
|
||||
// save makes a normal playlist of the songs the smart playlist gives now (the ones that variant shows).
|
||||
|
|
@ -231,7 +245,8 @@ func (h *smartHandlers) save(c *gin.Context) {
|
|||
if strings.TrimSpace(name) == "" {
|
||||
name = p.Name
|
||||
}
|
||||
keepAsPlaylist(c, h.playlists, user, name, tracks)
|
||||
name, description := automaticName(c, h.naming, req.AutoName, req.Lang, "smart", tracks, p.Rules.Summary(), name)
|
||||
keepAsPlaylist(c, h.playlists, user, name, description, tracks)
|
||||
}
|
||||
|
||||
// genres lists the genres of the library, to choose from in a rule: each with the number of songs, the
|
||||
|
|
@ -304,7 +319,7 @@ func (h *smartHandlers) suggestedSave(c *gin.Context) {
|
|||
}
|
||||
user := currentUserID(c)
|
||||
key := c.Param("key")
|
||||
_, tracks, err := h.svc.SuggestedTracks(c.Request.Context(), user, key, variant)
|
||||
sg, tracks, err := h.svc.SuggestedTracks(c.Request.Context(), user, key, variant)
|
||||
if err != nil {
|
||||
writeSuggestedError(c, err)
|
||||
return
|
||||
|
|
@ -317,5 +332,6 @@ func (h *smartHandlers) suggestedSave(c *gin.Context) {
|
|||
if name == "" {
|
||||
name = key // a client says the name in its language; this is only for one that does not
|
||||
}
|
||||
keepAsPlaylist(c, h.playlists, user, name, tracks)
|
||||
name, description := automaticName(c, h.naming, req.AutoName, req.Lang, "smart", tracks, sg.Rules.Summary(), name)
|
||||
keepAsPlaylist(c, h.playlists, user, name, description, tracks)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -186,3 +186,142 @@ func TestNameErrorsAreTheOnesOfWhatIsNamed(t *testing.T) {
|
|||
t.Errorf("bad variant: %d", r.Code)
|
||||
}
|
||||
}
|
||||
|
||||
// ---- names made by themselves ----
|
||||
|
||||
func playlistNamed(t *testing.T, m *mixAPI, id any) map[string]any {
|
||||
t.Helper()
|
||||
r := do(t, m.h, "GET", fmt.Sprintf("/api/v1/playlists/%v", id), m.alice, nil)
|
||||
if r.Code != http.StatusOK {
|
||||
t.Fatalf("playlist %v: %d %v", id, r.Code, r.Body)
|
||||
}
|
||||
return r.Body
|
||||
}
|
||||
|
||||
func TestWhenClaudeIsOnAKeptMixIsNamedByClaude(t *testing.T) {
|
||||
c := &askedClaude{}
|
||||
m := newNamingAPI(t, c, true)
|
||||
r := do(t, m.h, "POST", "/api/v1/mixes/genre%3Ahard%20rock/playlist", m.alice, map[string]any{"name": "Mix Hard Rock", "auto_name": true, "lang": "it", "variant": 1})
|
||||
if r.Code != http.StatusCreated || r.Body["name"] != "Riff senza sosta" {
|
||||
t.Fatalf("%d %v", r.Code, r.Body)
|
||||
}
|
||||
if got := playlistNamed(t, m, r.Body["id"]); got["description"] != "Hard rock che non hai ancora ascoltato." {
|
||||
t.Errorf("playlist = %v: the line of description is kept too", got)
|
||||
}
|
||||
if len(c.asked) != 1 || c.asked[0].Kind != "mix" || c.asked[0].Language != "it" || c.asked[0].Tracks != 36 {
|
||||
t.Errorf("asked %+v", c.asked)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTheNameGivenIsKeptWhenNothingAsksForAnAutomaticOne(t *testing.T) {
|
||||
c := &askedClaude{}
|
||||
m := newNamingAPI(t, c, true)
|
||||
for name, body := range map[string]map[string]any{
|
||||
"auto_name false": {"name": "My own", "variant": 1},
|
||||
"auto_name absent": {"name": "My own"},
|
||||
} {
|
||||
r := do(t, m.h, "POST", "/api/v1/mixes/genre%3Ahard%20rock/playlist", m.alice, body)
|
||||
if r.Code != http.StatusCreated || r.Body["name"] != "My own" {
|
||||
t.Errorf("%s: %d %v", name, r.Code, r.Body)
|
||||
}
|
||||
}
|
||||
if len(c.asked) != 0 {
|
||||
t.Errorf("Claude was asked for a name nobody wanted: %v", c.asked)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWithoutClaudeAnAutomaticNameIsTheOneGiven(t *testing.T) {
|
||||
for name, tc := range map[string]struct {
|
||||
claude *askedClaude
|
||||
on bool
|
||||
}{
|
||||
"the provider is off": {&askedClaude{}, false},
|
||||
"Claude fails": {&askedClaude{err: providers.ErrUnreachable}, true},
|
||||
"Claude declines": {&askedClaude{err: anthropic.ErrNoName}, true},
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
m := newNamingAPI(t, tc.claude, tc.on)
|
||||
r := do(t, m.h, "POST", "/api/v1/mixes/genre%3Ahard%20rock/playlist", m.alice, map[string]any{"name": "Hard Rock Mix", "auto_name": true})
|
||||
if r.Code != http.StatusCreated || r.Body["name"] != "Hard Rock Mix" {
|
||||
t.Fatalf("%d %v", r.Code, r.Body)
|
||||
}
|
||||
if got := playlistNamed(t, m, r.Body["id"]); got["description"] != "" {
|
||||
t.Errorf("a description came from nowhere: %v", got)
|
||||
}
|
||||
if !tc.on && len(tc.claude.asked) != 0 {
|
||||
t.Error("Claude was asked with the provider off")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestASmartAndASuggestedPlaylistAreNamedByClaudeWhenKept(t *testing.T) {
|
||||
c := &askedClaude{}
|
||||
m := newNamingAPI(t, c, true)
|
||||
id := smartMade(t, m, map[string]any{"name": "Fresh", "limit": 8, "rules": map[string]any{"genres": []string{"rock"}, "never_played": true}})
|
||||
r := do(t, m.h, "POST", fmt.Sprintf("%s/%d/playlist", sp, id), m.alice, map[string]any{"name": "Fresh", "auto_name": true, "lang": "en"})
|
||||
if r.Code != http.StatusCreated || r.Body["name"] != "Riff senza sosta" {
|
||||
t.Fatalf("smart: %d %v", r.Code, r.Body)
|
||||
}
|
||||
if got := c.asked[0]; got.Kind != "smart" || got.Hint != "genres: rock; never played" {
|
||||
t.Errorf("smart facts = %+v", got)
|
||||
}
|
||||
s := do(t, m.h, "POST", sp+"/suggested/never-played/playlist", m.alice, map[string]any{"name": "Never played", "auto_name": true, "lang": "en"})
|
||||
if s.Code != http.StatusCreated || s.Body["name"] != "Riff senza sosta" {
|
||||
t.Fatalf("suggested: %d %v", s.Code, s.Body)
|
||||
}
|
||||
if got := c.asked[1]; got.Kind != "smart" || got.Hint != "never played" {
|
||||
t.Errorf("suggested facts = %+v", got)
|
||||
}
|
||||
// Without the request for it, the name stays.
|
||||
n := do(t, m.h, "POST", sp+"/suggested/never-played/playlist", m.alice, map[string]any{"name": "Never played"})
|
||||
if n.Body["name"] != "Never played" || len(c.asked) != 2 {
|
||||
t.Errorf("%v with %d questions", n.Body, len(c.asked))
|
||||
}
|
||||
}
|
||||
|
||||
func TestASmartPlaylistWithNoNameIsNamedByClaudeWhenItIsOn(t *testing.T) {
|
||||
c := &askedClaude{}
|
||||
m := newNamingAPI(t, c, true)
|
||||
r := do(t, m.h, "POST", sp, m.alice, map[string]any{"name": " ", "rules": map[string]any{"genres": []string{"hard rock"}}, "limit": 12, "lang": "it"})
|
||||
if r.Code != http.StatusCreated || r.Body["name"] != "Riff senza sosta" || r.Body["description"] != "Hard rock che non hai ancora ascoltato." {
|
||||
t.Fatalf("%d %v", r.Code, r.Body)
|
||||
}
|
||||
if got := c.asked[0]; got.Kind != "smart" || got.Tracks != 12 || got.Language != "it" || got.Hint != "genres: hard rock" {
|
||||
t.Errorf("facts = %+v", got)
|
||||
}
|
||||
// A name that was given is the name, even with Claude on.
|
||||
own := do(t, m.h, "POST", sp, m.alice, map[string]any{"name": "Mine", "rules": map[string]any{}})
|
||||
if own.Body["name"] != "Mine" || len(c.asked) != 1 {
|
||||
t.Errorf("%v after %d questions", own.Body, len(c.asked))
|
||||
}
|
||||
}
|
||||
|
||||
func TestASmartPlaylistWithNoNameNeedsOneWhenClaudeCannotMakeIt(t *testing.T) {
|
||||
for name, m := range map[string]*mixAPI{
|
||||
"off": newNamingAPI(t, &askedClaude{}, false),
|
||||
"failing": newNamingAPI(t, &askedClaude{err: providers.ErrUnreachable}, true),
|
||||
} {
|
||||
r := do(t, m.h, "POST", sp, m.alice, map[string]any{"name": "", "rules": map[string]any{"genres": []string{"hard rock"}}})
|
||||
if r.Code != http.StatusBadRequest || errCode(r) != "invalid_input" {
|
||||
t.Errorf("%s: %d %v", name, r.Code, r.Body)
|
||||
}
|
||||
if list := do(t, m.h, "GET", sp, m.alice, nil); list.Body["total"] != float64(0) {
|
||||
t.Errorf("%s: a smart playlist was kept with no name: %v", name, list.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestTheClientCanAskWhetherNamesAreAutomatic(t *testing.T) {
|
||||
on := newNamingAPI(t, &askedClaude{}, true)
|
||||
if r := do(t, on.h, "GET", "/api/v1/naming", on.alice, nil); r.Code != http.StatusOK || r.Body["auto"] != true {
|
||||
t.Errorf("on: %d %v", r.Code, r.Body)
|
||||
}
|
||||
off := newNamingAPI(t, &askedClaude{}, false)
|
||||
if r := do(t, off.h, "GET", "/api/v1/naming", off.alice, nil); r.Code != http.StatusOK || r.Body["auto"] != false || len(r.Body) != 1 {
|
||||
t.Errorf("off: %d %v", r.Code, r.Body)
|
||||
}
|
||||
if r := do(t, off.h, "GET", "/api/v1/naming", "", nil); r.Code != http.StatusUnauthorized {
|
||||
t.Errorf("no token: %d", r.Code)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ type mixService interface {
|
|||
type namingService interface {
|
||||
FactsOf(ctx context.Context, kind string, tracks []catalog.Track, hint string) (naming.Facts, error)
|
||||
Suggest(ctx context.Context, f naming.Facts, lang string) (naming.Suggestion, error)
|
||||
Auto(ctx context.Context) bool
|
||||
}
|
||||
|
||||
// smartService is what the handlers need from smart.Service.
|
||||
|
|
@ -282,15 +283,16 @@ func NewRouter(d Deps) *gin.Engine {
|
|||
protected.POST("/playlists/:id/tracks", pl.addTracks)
|
||||
protected.DELETE("/playlists/:id/tracks/:item", pl.removeItem)
|
||||
protected.PATCH("/playlists/:id/tracks/:item", pl.moveItem)
|
||||
mx := &mixHandlers{svc: d.Mixes, playlists: d.Playlists}
|
||||
mx := &mixHandlers{svc: d.Mixes, playlists: d.Playlists, naming: d.Naming}
|
||||
protected.GET("/mixes", mx.list)
|
||||
protected.GET("/mixes/:id", mx.get)
|
||||
protected.POST("/mixes/:id/playlist", mx.save)
|
||||
nm := &namingHandlers{svc: d.Naming, playlists: d.Playlists, mixes: d.Mixes, smart: d.Smart}
|
||||
protected.GET("/naming", nm.status)
|
||||
protected.POST("/playlists/:id/suggest-name", nm.playlistName)
|
||||
protected.POST("/mixes/:id/suggest-name", nm.mixName)
|
||||
protected.POST("/smart-playlists/:id/suggest-name", nm.smartName)
|
||||
sm := &smartHandlers{svc: d.Smart, playlists: d.Playlists}
|
||||
sm := &smartHandlers{svc: d.Smart, playlists: d.Playlists, naming: d.Naming}
|
||||
protected.GET("/genres", sm.genres)
|
||||
protected.GET("/smart-playlists", sm.list)
|
||||
protected.POST("/smart-playlists", sm.create)
|
||||
|
|
|
|||
|
|
@ -1667,6 +1667,29 @@ paths:
|
|||
'401': {$ref: '#/components/responses/Unauthorized'}
|
||||
'404': {$ref: '#/components/responses/PlaylistNotFound'}
|
||||
|
||||
/naming:
|
||||
get:
|
||||
tags: [Smart playlists]
|
||||
operationId: getNamingStatus
|
||||
summary: Whether names are made by themselves
|
||||
description: |
|
||||
`auto` is true when the `anthropic` provider is on with its key: a playlist that is kept from a mix or a smart
|
||||
playlist with `auto_name`, and a smart playlist made with no name, are then named by Claude. A page asks this so
|
||||
that it does not ask for a name that Claude will make.
|
||||
security: [{bearerAuth: []}]
|
||||
responses:
|
||||
'200':
|
||||
description: The status.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required: [auto]
|
||||
properties:
|
||||
auto: {type: boolean}
|
||||
'401': {$ref: '#/components/responses/Unauthorized'}
|
||||
|
||||
/playlists/{id}/suggest-name:
|
||||
parameters:
|
||||
- {$ref: '#/components/parameters/Id'}
|
||||
|
|
@ -3596,6 +3619,8 @@ components:
|
|||
properties:
|
||||
name: {type: string, maxLength: 200, description: "The name of the playlist; blank or absent means the title of the mix."}
|
||||
variant: {type: integer, minimum: 0, maximum: 1000000, description: "The variant the client showed; absent means the mix of the day."}
|
||||
auto_name: {type: boolean, default: false, description: "When true and the Claude provider is on, the playlist is named by Claude from its songs (with a line of description), and `name` is only the name to give it when Claude is off, fails or declines."}
|
||||
lang: {type: string, maxLength: 16, description: "The language of a name that Claude makes: `en` or `it`. Absent or another: English."}
|
||||
|
||||
GenreList:
|
||||
type: object
|
||||
|
|
@ -3709,9 +3734,9 @@ components:
|
|||
CreateSmartPlaylist:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required: [name]
|
||||
properties:
|
||||
name: {type: string, minLength: 1, maxLength: 200, description: Trimmed.}
|
||||
name: {type: string, maxLength: 200, description: "Trimmed. It can be blank or absent only when the Claude provider is on (see `GET /naming`): Claude then names the playlist from the songs its rules give, and a failure is `invalid_input`."}
|
||||
lang: {type: string, maxLength: 16, description: "The language of a name that Claude makes: `en` or `it`. Absent or another: English."}
|
||||
description: {type: string, maxLength: 2000}
|
||||
rules: {$ref: '#/components/schemas/SmartRules'}
|
||||
sort: {$ref: '#/components/schemas/SmartSort'}
|
||||
|
|
@ -3754,6 +3779,8 @@ components:
|
|||
properties:
|
||||
name: {type: string, maxLength: 200, description: "The name of the playlist; blank or absent means the name of the smart playlist."}
|
||||
variant: {type: integer, minimum: 0, maximum: 1000000, description: "The variant the client showed; absent means the songs of the day."}
|
||||
auto_name: {type: boolean, default: false, description: "When true and the Claude provider is on, the playlist is named by Claude from its songs (with a line of description), and `name` is only the name to give it when Claude is off, fails or declines."}
|
||||
lang: {type: string, maxLength: 16, description: "The language of a name that Claude makes: `en` or `it`. Absent or another: English."}
|
||||
|
||||
Playlist:
|
||||
type: object
|
||||
|
|
|
|||
|
|
@ -155,6 +155,13 @@ func (s *Service) Suggest(ctx context.Context, f Facts, language string) (Sugges
|
|||
return out, nil
|
||||
}
|
||||
|
||||
// Auto says whether names are made by themselves: the Claude provider is on, with its key. A provider that cannot be
|
||||
// read counts as off.
|
||||
func (s *Service) Auto(ctx context.Context) bool {
|
||||
_, on, err := s.settings.Active(ctx, providers.Anthropic)
|
||||
return err == nil && on
|
||||
}
|
||||
|
||||
// junkArtists are the names that stand for nobody.
|
||||
var junkArtists = map[string]bool{"unknown artist": true, "various artists": true, "": true}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue