-
Notifications
You must be signed in to change notification settings - Fork 120
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 #5553 from gooddata/ach/gen-ai-feedback
RELATED: F1-645 user feedback in chat
- Loading branch information
Showing
19 changed files
with
268 additions
and
10 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
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
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
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
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
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
37 changes: 37 additions & 0 deletions
37
libs/sdk-ui-gen-ai/src/store/sideEffects/onUserFeedback.ts
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// (C) 2024 GoodData Corporation | ||
|
||
import { IAnalyticalBackend } from "@gooddata/sdk-backend-spi"; | ||
import { PayloadAction } from "@reduxjs/toolkit"; | ||
import { call, getContext, select } from "redux-saga/effects"; | ||
import { extractError } from "./utils.js"; | ||
import { GenAIChatInteractionUserFeedback } from "@gooddata/sdk-model"; | ||
import { messagesSelector } from "../messages/messagesSelectors.js"; | ||
import { Message } from "../../model.js"; | ||
|
||
/** | ||
* Save user feedback to server. | ||
* Optimistic update, ignoring the error. | ||
* @internal | ||
*/ | ||
export function* onUserFeedback({ | ||
payload, | ||
}: PayloadAction<{ | ||
assistantMessageId: string; | ||
feedback: GenAIChatInteractionUserFeedback; | ||
}>) { | ||
try { | ||
// Retrieve backend from context | ||
const backend: IAnalyticalBackend = yield getContext("backend"); | ||
const workspace: string = yield getContext("workspace"); | ||
const messages: Message[] = yield select(messagesSelector); | ||
const message = messages.find((message) => message.localId === payload.assistantMessageId); | ||
|
||
if (!message?.id) return; | ||
|
||
const chatThread = backend.workspace(workspace).genAI().getChatThread(); | ||
|
||
yield call([chatThread, chatThread.saveUserFeedback], message.id, payload.feedback); | ||
} catch (e) { | ||
console.warn(`Failed to save user feedback: ${extractError(e)}`); | ||
} | ||
} |
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
Oops, something went wrong.