Skip to content

Commit 6d1f225

Browse files
committed
Enhance feedback API and modal to support optional workflow information
- Added an optional 'workflow' field to the feedback API request type for improved context. - Updated the feedback submission process to include the workflow in the metadata sent to Langfuse. - Modified the FeedbackModal to conditionally include the active workflow in the feedback context. These changes aim to provide better tracking of user feedback related to specific workflows, enhancing the overall feedback management experience.
1 parent e2be93d commit 6d1f225

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

components/frontend/src/app/api/feedback/route.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { getLangfuseClient } from '@/lib/langfuseClient';
1515
* - username: string
1616
* - projectName: string
1717
* - sessionName: string
18+
* - workflow?: string (optional - active workflow name)
1819
* - context?: string (what the user was working on)
1920
* - includeTranscript?: boolean
2021
* - transcript?: Array<{ role: string; content: string; timestamp?: string }>
@@ -27,6 +28,7 @@ type FeedbackRequest = {
2728
username: string;
2829
projectName: string;
2930
sessionName: string;
31+
workflow?: string;
3032
context?: string;
3133
includeTranscript?: boolean;
3234
transcript?: Array<{ role: string; content: string; timestamp?: string }>;
@@ -43,6 +45,7 @@ export async function POST(request: NextRequest) {
4345
username,
4446
projectName,
4547
sessionName,
48+
workflow,
4649
context,
4750
includeTranscript,
4851
transcript,
@@ -75,7 +78,7 @@ export async function POST(request: NextRequest) {
7578
}
7679

7780
if (context) {
78-
commentParts.push(`Context: ${context}`);
81+
commentParts.push(`\nMessage:\n${context}`);
7982
}
8083

8184
if (includeTranscript && transcript && transcript.length > 0) {
@@ -96,6 +99,10 @@ export async function POST(request: NextRequest) {
9699
session: sessionName,
97100
user: username,
98101
};
102+
103+
if (workflow) {
104+
metadata.workflow = workflow;
105+
}
99106

100107
// Send feedback using LangfuseWeb SDK
101108
langfuse.score({

components/frontend/src/components/feedback/FeedbackModal.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,8 @@ export function FeedbackModal({
8383
contextParts.push(`Initial prompt: ${feedbackContext.initialPrompt.substring(0, 200)}`);
8484
}
8585

86-
if (feedbackContext.activeWorkflow) {
87-
contextParts.push(`Workflow: ${feedbackContext.activeWorkflow}`);
88-
}
89-
9086
if (messageContent) {
91-
contextParts.push(`Response being rated: ${messageContent.substring(0, 500)}`);
87+
contextParts.push(messageContent.substring(0, 500));
9288
}
9389

9490
const transcript = includeTranscript
@@ -104,6 +100,7 @@ export function FeedbackModal({
104100
username: feedbackContext.username,
105101
projectName: feedbackContext.projectName,
106102
sessionName: feedbackContext.sessionName,
103+
workflow: feedbackContext.activeWorkflow || undefined,
107104
context: contextParts.join("; "),
108105
includeTranscript,
109106
transcript,

0 commit comments

Comments
 (0)