Skip to content

Commit

Permalink
backend: working on search with chat
Browse files Browse the repository at this point in the history
  • Loading branch information
NickSavage committed Nov 28, 2024
1 parent d6dfdf9 commit d1df329
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
7 changes: 5 additions & 2 deletions go-backend/handlers/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/google/uuid"
"github.com/gorilla/mux"
"github.com/lib/pq"
)

const MODEL = "gpt-4"
Expand Down Expand Up @@ -264,8 +265,8 @@ func (s *Handler) GetChatCompletion(userID int, conversationID string) (models.C
query := `
INSERT INTO chat_completions (
user_id, conversation_id, sequence_number, role,
content, model, tokens
) VALUES ($1, $2, $3, $4, $5, $6, $7)
content, model, tokens, card_chunks
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
RETURNING id, created_at
`
err = s.DB.QueryRow(
Expand All @@ -277,6 +278,8 @@ func (s *Handler) GetChatCompletion(userID int, conversationID string) (models.C
completion.Content,
completion.Model,
completion.Tokens,
pq.Array(completion.ReferencedCards), // Convert Go slice to PostgreSQL array

).Scan(&completion.ID, &completion.CreatedAt)

if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions go-backend/handlers/chat_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package handlers

import (
"bytes"
"encoding/json"
// "bytes"
// "encoding/json"
"go-backend/models"
"go-backend/tests"
"log"
Expand Down
1 change: 1 addition & 0 deletions go-backend/schema/0031-chat-add-cards.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE chat_completions ADD COLUMN card_chunks integer[];
2 changes: 1 addition & 1 deletion zettelkasten-front/src/models/Chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface ChatCompletion {
}

export interface ConversationSummary {
conversation_id: string;
id: string;
message_count: number;
created_at: Date;
model: string;
Expand Down

0 comments on commit d1df329

Please sign in to comment.