Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions coderd/database/dbgen/dbgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,10 @@ func ChatMessage(t testing.TB, db database.Store, seed database.ChatMessage) dat
content = string(seed.Content.RawMessage)
}
role := takeFirst(seed.Role, database.ChatMessageRoleUser)
apiKeyID := seed.APIKeyID.String
// Mint a real API key for user turns so the api_key_id foreign key is
// satisfied. Without a creator we leave it empty, which the insert query
// stores as NULL.
if role == database.ChatMessageRoleUser && apiKeyID == "" &&
seed.CreatedBy.Valid && seed.CreatedBy.UUID != uuid.Nil {
key, _ := APIKey(t, db, database.APIKey{UserID: seed.CreatedBy.UUID})
apiKeyID = key.ID
}

msgs, err := db.InsertChatMessages(genCtx, database.InsertChatMessagesParams{
ChatID: seed.ChatID,
CreatedBy: []uuid.UUID{seed.CreatedBy.UUID},
APIKeyID: []string{apiKeyID},
ModelConfigID: []uuid.UUID{seed.ModelConfigID.UUID},
ReasoningEffort: []string{string(seed.ReasoningEffort.ChatReasoningEffort)},
Role: []database.ChatMessageRole{role},
Expand Down
2 changes: 0 additions & 2 deletions coderd/database/dump.sql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE chat_messages
ADD COLUMN api_key_id text;

ALTER TABLE chat_queued_messages
ADD COLUMN api_key_id text;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE chat_messages
Comment thread
ibetitsmike marked this conversation as resolved.
Comment thread
ibetitsmike marked this conversation as resolved.
DROP COLUMN api_key_id;
Comment thread
ibetitsmike marked this conversation as resolved.
Comment thread
ibetitsmike marked this conversation as resolved.

ALTER TABLE chat_queued_messages
DROP COLUMN api_key_id;
Comment thread
ibetitsmike marked this conversation as resolved.
2 changes: 0 additions & 2 deletions coderd/database/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions coderd/database/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11939,12 +11939,9 @@ func TestInsertChatMessages(t *testing.T) {

insertMessage := func(t *testing.T, store database.Store, ctx context.Context, chatID, userID, modelConfigID uuid.UUID, content string) {
t.Helper()
apiKey, _ := dbgen.APIKey(t, store, database.APIKey{ID: uuid.NewString(), UserID: userID})

_, err := store.InsertChatMessages(ctx, database.InsertChatMessagesParams{
ChatID: chatID,
CreatedBy: []uuid.UUID{userID},
APIKeyID: []string{apiKey.ID},
ModelConfigID: []uuid.UUID{modelConfigID},
Role: []database.ChatMessageRole{database.ChatMessageRoleUser},
ContentVersion: []int16{chatprompt.CurrentContentVersion},
Expand Down Expand Up @@ -12003,12 +12000,9 @@ func TestInsertChatMessages(t *testing.T) {
t.Parallel()

store, ctx, user, chat, _, modelConfigA := setupChat(t)
apiKey, _ := dbgen.APIKey(t, store, database.APIKey{ID: uuid.NewString(), UserID: user.ID})

msgs, err := store.InsertChatMessages(ctx, database.InsertChatMessagesParams{
ChatID: chat.ID,
CreatedBy: []uuid.UUID{user.ID, uuid.Nil, uuid.Nil},
APIKeyID: []string{apiKey.ID, "", ""},
ModelConfigID: []uuid.UUID{modelConfigA.ID, modelConfigA.ID, modelConfigA.ID},
Role: []database.ChatMessageRole{database.ChatMessageRoleUser, database.ChatMessageRoleAssistant, database.ChatMessageRoleTool},
ContentVersion: []int16{chatprompt.CurrentContentVersion, chatprompt.CurrentContentVersion, chatprompt.CurrentContentVersion},
Expand Down
Loading
Loading