| 73 | } |
| 74 | |
| 75 | func (p *Server) preferredShortTextCandidates( |
| 76 | chat database.Chat, |
| 77 | keys chatprovider.ProviderAPIKeys, |
| 78 | ) []shortTextCandidate { |
| 79 | if p.shouldUseAIGatewayRouting() { |
| 80 | return nil |
| 81 | } |
| 82 | |
| 83 | candidates := make([]shortTextCandidate, 0, len(preferredTitleModels)+1) |
| 84 | userAgent := chatprovider.UserAgent() |
| 85 | extraHeaders := chatprovider.CoderHeaders(chat) |
| 86 | for _, candidate := range preferredTitleModels { |
| 87 | model, err := chatprovider.ModelFromConfig( |
| 88 | candidate.provider, candidate.model, keys, userAgent, |
| 89 | extraHeaders, |
| 90 | nil, |
| 91 | ) |
| 92 | if err == nil { |
| 93 | candidates = append(candidates, shortTextCandidate{ |
| 94 | provider: candidate.provider, |
| 95 | model: candidate.model, |
| 96 | route: newDirectModelRoute(candidate.provider, keys), |
| 97 | lm: model, |
| 98 | }) |
| 99 | } |
| 100 | } |
| 101 | return candidates |
| 102 | } |
| 103 | |
| 104 | func selectPreferredConfiguredShortTextModelConfig( |
| 105 | configs []database.ChatModelConfig, |