KomaSattarovK
Convex Community2y ago
3 replies
KomaSattarov

Langchain + Convex, please...

Hey there beautiful people at convex.dev!
I am thinking of implementing an AI functionality to my nextjs typescript app. The convex schema looks like this:
export default defineSchema({
documents: defineTable({
title: v.string(),
userId: v.string(),
content: v.optional(v.string()),
category: v.optional(v.string()),
isChecked: v.optional(v.boolean()),
trScore: v.optional(v.number()), //Task Response Score
ccScore: v.optional(v.number()), //Coherence & cohesion Score
lrScore: v.optional(v.number()), //Lexical Resources Score
grScore: v.optional(v.number()), //Grammar Range & accuracy Score
overallScore: v.optional(v.number()),
trScoreFeedback: v.optional(v.string()),
ccScoreFeedback: v.optional(v.string()),
lrScoreFeedback: v.optional(v.string()),
grScoreFeedback: v.optional(v.string()),
overallScoreFeedback: v.optional(v.string()),
}).index("by_user", ["userId"]),
});
I ve already set up an api call to OpenAI to assess the user's written work, create scores and feedback for each scoring criteria, and store those scores.
However, I now, want to create a context aware chat functionality that already knows the document's content, the assessment scores, and the feedback for each score.
The main idea of this chat function is to allow users to ask questions related to ONLY this document. For example, user may ask "Why my Task Response score was low, and how could I improve it?",
and the AI should create a response based on its knowledge of document content, task response score and feedback.

I don't know how to do it. Please, guide me, show me the way...
I am new to coding, so, detailed guidence would be highly appreciated.
Thank you very much!
Was this page helpful?