-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from telpirion/dev
feat: adds PII protection
- Loading branch information
Showing
2 changed files
with
19 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ var ( | |
r *gin.Engine | ||
projectID string | ||
userEmail string = "[email protected]" | ||
encryptedEmail string | ||
userEmailParam string = "user" | ||
convoContext string | ||
contextTokens int32 | ||
|
@@ -77,11 +78,16 @@ func startConversation(c *gin.Context) { | |
writeTimeSeriesValue(projectID, "Start of conversation") | ||
// extractParams will redirect if user isn't logged in. | ||
userEmail = extractParams(c) | ||
encryptedEmail = userEmail | ||
|
||
if os.Getenv("CONFIGURATION_NAME") != "HerodotusDev" { | ||
encryptedEmail = transformEmail(userEmail) | ||
} | ||
|
||
LogInfo("Start conversation request received") | ||
|
||
// create a new conversation context | ||
convoHistory, err := getConversation(userEmail, projectID) | ||
convoHistory, err := getConversation(encryptedEmail, projectID) | ||
if err != nil { | ||
LogError(fmt.Sprintf("couldn't get conversation history: %v\n", err)) | ||
} | ||
|
@@ -203,7 +209,7 @@ func updateDatabase(projectID, userMessage, modelName, promptTemplateName, botRe | |
// Store the conversation in Firestore and update the cachedContext | ||
// This is dual-entry accounting so that we don't have to query Firestore | ||
// every time to update the cached context | ||
documentID, err := saveConversation(*convo, userEmail, projectID) | ||
documentID, err := saveConversation(*convo, encryptedEmail, projectID) | ||
if err != nil { | ||
return "", fmt.Errorf("couldn't save conversation: %v", err) | ||
} | ||
|