Skip to content

Commit

Permalink
Restore functionality for sending feedback to LangSmith.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnguonly committed May 16, 2024
1 parent fa16eec commit cb323df
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion frontend/src/components/LangSmithActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,34 @@ export function LangSmithActions(props: { runId: string, threadId: string }) {
} | null>(null);
const sendFeedback = async (score: number) => {
setState({ score, inflight: true });

// send feedback to LangSmith
// this is a no-op if tracing is disabled in the backend
await fetch(`/runs/feedback`, {
method: "POST",
body: JSON.stringify({
run_id: props.runId,
key: "user_score",
score: score,
}),
headers: {
"Content-Type": "application/json",
},
});

// score thread, thread will be used as few shot example
// few shot score must be 1 or 0
const fewShotScore = score > 0 ? 1 : 0;
await fetch(`/api/threads/${props.threadId}/state`, {
method: "PATCH",
body: JSON.stringify({
metadata: {score: score},
metadata: {score: fewShotScore},
}),
headers: {
"Content-Type": "application/json",
},
});

setState({ score, inflight: false });
};
return (
Expand Down

0 comments on commit cb323df

Please sign in to comment.