Skip to content

Commit

Permalink
feat(AIReplySection): pass aiResponseId to handleVote and update Grap…
Browse files Browse the repository at this point in the history
…hQL query for AI replies
  • Loading branch information
MrOrz committed Jan 26, 2025
1 parent 663974b commit 50aedc8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 8 additions & 4 deletions components/AIReplySection.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ const useStyles = makeStyles(theme => ({
},
}));

function AIReplySection({ defaultExpand = false, aiReplyText = '', traceId }) {
function AIReplySection({
defaultExpand = false,
aiReplyText = '',
aiResponseId,
}) {
const [expand, setExpand] = useState(defaultExpand);
const classes = useStyles();

Expand All @@ -37,9 +41,9 @@ function AIReplySection({ defaultExpand = false, aiReplyText = '', traceId }) {

const handleVote = async (vote: 1 | -1) => {
await langfuseWeb.score({
traceId,
name: 'ai_reply_feedback',
value: vote === 1 ? 1 : 0,
traceId: aiResponseId,
name: 'user-feedback',
value: vote,
});
};

Expand Down
2 changes: 2 additions & 0 deletions pages/article/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ const LOAD_ARTICLE = gql`
...CurrentRepliesData
}
aiReplies {
id
text
}
...RelatedArticleData
Expand Down Expand Up @@ -575,6 +576,7 @@ function ArticlePage() {

{article.aiReplies?.length > 0 && (
<AIReplySection
aiResponseId={article.aiReplies[0].id}
defaultExpand={replyCount === 0}
aiReplyText={article.aiReplies[0].text}
/>
Expand Down

0 comments on commit 50aedc8

Please sign in to comment.