MCPcopy Index your code
hub / github.com/coder/coder / resolveFallbackModelConfigID

Function resolveFallbackModelConfigID

coderd/x/chatd/chatd.go:1988–2014  ·  view source on GitHub ↗
(
	ctx context.Context,
	store database.Store,
	modelConfigID uuid.UUID,
)

Source from the content-addressed store, hash-verified

1986}
1987
1988func 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,

Calls 6

NewMethod · 0.65
IsMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected