( ctx context.Context, store database.Store, modelConfigID uuid.UUID, )
| 1986 | } |
| 1987 | |
| 1988 | func resolveFallbackModelConfigID( |
| 1989 | ctx context.Context, |
| 1990 | store database.Store, |
| 1991 | modelConfigID uuid.UUID, |
| 1992 | ) (uuid.UUID, error) { |
| 1993 | chatdCtx := chatdModelConfigLookupContext(ctx) |
| 1994 | if modelConfigID != uuid.Nil { |
| 1995 | if _, err := store.GetChatModelConfigByID(chatdCtx, modelConfigID); err == nil { |
| 1996 | return modelConfigID, nil |
| 1997 | } else if !errors.Is(err, sql.ErrNoRows) { |
| 1998 | return uuid.Nil, xerrors.Errorf( |
| 1999 | "get chat model config %s: %w", |
| 2000 | modelConfigID, |
| 2001 | err, |
| 2002 | ) |
| 2003 | } |
| 2004 | } |
| 2005 | |
| 2006 | defaultConfig, err := store.GetDefaultChatModelConfig(chatdCtx) |
| 2007 | if err != nil { |
| 2008 | if errors.Is(err, sql.ErrNoRows) { |
| 2009 | return uuid.Nil, xerrors.New("no default chat model config is available") |
| 2010 | } |
| 2011 | return uuid.Nil, xerrors.Errorf("get default chat model config: %w", err) |
| 2012 | } |
| 2013 | return defaultConfig.ID, nil |
| 2014 | } |
| 2015 | |
| 2016 | // EditMessage marks the old user message as deleted, soft-deletes all |
| 2017 | // following messages, inserts a new message with the updated content, |
no test coverage detected