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

Function BuildSingleUserChatMessageInsertParams

coderd/x/chatd/chatd.go:4076–4094  ·  view source on GitHub ↗

BuildSingleUserChatMessageInsertParams creates batch insert params for one user message, requiring an apiKeyID for AI Gateway attribution.

(
	chatID uuid.UUID,
	apiKeyID string,
	content pqtype.NullRawMessage,
	visibility database.ChatMessageVisibility,
	modelConfigID uuid.UUID,
	contentVersion int16,
	createdBy uuid.UUID,
)

Source from the content-addressed store, hash-verified

4074// BuildSingleUserChatMessageInsertParams creates batch insert params for
4075// one user message, requiring an apiKeyID for AI Gateway attribution.
4076func BuildSingleUserChatMessageInsertParams(
4077 chatID uuid.UUID,
4078 apiKeyID string,
4079 content pqtype.NullRawMessage,
4080 visibility database.ChatMessageVisibility,
4081 modelConfigID uuid.UUID,
4082 contentVersion int16,
4083 createdBy uuid.UUID,
4084) database.InsertChatMessagesParams {
4085 params := database.InsertChatMessagesParams{ //nolint:exhaustruct // Fields populated by appendUserChatMessage.
4086 ChatID: chatID,
4087 }
4088 msg := newUserChatMessage(apiKeyID, content, visibility, modelConfigID, contentVersion)
4089 if createdBy != uuid.Nil {
4090 msg = msg.withCreatedBy(createdBy)
4091 }
4092 appendUserChatMessage(&params, msg)
4093 return params
4094}
4095
4096// insertUserMessageAndSetPending inserts a user message, transitions the
4097// chat to pending when needed, and returns the refreshed chat row.

Callers 1

Calls 3

newUserChatMessageFunction · 0.85
appendUserChatMessageFunction · 0.85
withCreatedByMethod · 0.45

Tested by

no test coverage detected