| 8 | ) |
| 9 | |
| 10 | func MapProtoSettingsToModel(settings *userv1.Settings) *models.Settings { |
| 11 | // Map the slice of custom models |
| 12 | customModels := make([]models.CustomModel, len(settings.CustomModels)) |
| 13 | for i, m := range settings.CustomModels { |
| 14 | var id bson.ObjectID |
| 15 | |
| 16 | id, err := bson.ObjectIDFromHex(m.Id) |
| 17 | if err != nil { |
| 18 | id = bson.NewObjectID() |
| 19 | } |
| 20 | |
| 21 | customModels[i] = models.CustomModel{ |
| 22 | Id: id, |
| 23 | Slug: m.Slug, |
| 24 | Name: m.Name, |
| 25 | BaseUrl: m.BaseUrl, |
| 26 | APIKey: m.ApiKey, |
| 27 | ContextWindow: m.ContextWindow, |
| 28 | MaxOutput: m.MaxOutput, |
| 29 | InputPrice: m.InputPrice, |
| 30 | OutputPrice: m.OutputPrice, |
| 31 | Temperature: m.Temperature, |
| 32 | ParallelToolCalls: m.ParallelToolCalls, |
| 33 | Store: m.Store, |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | return &models.Settings{ |
| 38 | ShowShortcutsAfterSelection: settings.ShowShortcutsAfterSelection, |
| 39 | FullWidthPaperDebuggerButton: settings.FullWidthPaperDebuggerButton, |
| 40 | EnableCitationSuggestion: settings.EnableCitationSuggestion, |
| 41 | FullDocumentRag: settings.FullDocumentRag, |
| 42 | ShowedOnboarding: settings.ShowedOnboarding, |
| 43 | OpenAIAPIKey: settings.OpenaiApiKey, |
| 44 | CustomModels: customModels, |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | func MapModelSettingsToProto(settings *models.Settings) *userv1.Settings { |
| 49 | // Map the slice back to Proto |