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

Function insertUserTextMessage

coderd/x/chatd/chatd_test.go:6223–6250  ·  view source on GitHub ↗
(
	t *testing.T,
	db database.Store,
	chatID uuid.UUID,
	userID uuid.UUID,
	modelConfigID uuid.UUID,
	text string,
	contextLimit ...int64,
)

Source from the content-addressed store, hash-verified

6221}
6222
6223func insertUserTextMessage(
6224 t *testing.T,
6225 db database.Store,
6226 chatID uuid.UUID,
6227 userID uuid.UUID,
6228 modelConfigID uuid.UUID,
6229 text string,
6230 contextLimit ...int64,
6231) database.ChatMessage {
6232 t.Helper()
6233 require.LessOrEqual(t, len(contextLimit), 1)
6234
6235 contextLimitValue := int64(0)
6236 if len(contextLimit) == 1 {
6237 contextLimitValue = contextLimit[0]
6238 }
6239 content, err := chatprompt.MarshalParts([]codersdk.ChatMessagePart{codersdk.ChatMessageText(text)})
6240 require.NoError(t, err)
6241
6242 return dbgen.ChatMessage(t, db, database.ChatMessage{
6243 ChatID: chatID,
6244 CreatedBy: uuid.NullUUID{UUID: userID, Valid: true},
6245 ModelConfigID: uuid.NullUUID{UUID: modelConfigID, Valid: true},
6246 Role: database.ChatMessageRoleUser,
6247 Content: pqtype.NullRawMessage{RawMessage: content.RawMessage, Valid: true},
6248 ContextLimit: sql.NullInt64{Int64: contextLimitValue, Valid: contextLimitValue != 0},
6249 })
6250}
6251
6252// seedWorkspaceWithAgent creates a full workspace chain with a connected
6253// agent. This is the common setup needed by tests that exercise tool

Calls 4

MarshalPartsFunction · 0.92
ChatMessageTextFunction · 0.92
ChatMessageFunction · 0.92
HelperMethod · 0.65

Tested by

no test coverage detected