kyd-shared-badge 0.3.13 → 0.3.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/lib/context.ts +7 -0
- package/src/lib/routes.ts +9 -2
package/package.json
CHANGED
package/src/lib/context.ts
CHANGED
|
@@ -97,6 +97,8 @@ export function buildAllContextPrompt(cleanedData: any, reportGraphData: GraphIn
|
|
|
97
97
|
'Return natural language for the main reply.',
|
|
98
98
|
'When referring to the input JSON, use the term "Report Information" or "Report"',
|
|
99
99
|
'You are speaking to a non-technical user, ensure you do not use variable-esk language like "based on linkedin_provider", instead use "based the LinkedIn profile"',
|
|
100
|
+
'Do NOT recommend reviewing external sources or contacting anyone. Do NOT suggest actions such as "reach out", "discuss directly", "interview", or "collect more information". If the report lacks information to answer, state that plainly and stop.',
|
|
101
|
+
'Avoid advisory phrasing like "I recommend", "you should", or "consider". Provide only what the Report contains or explicitly lacks.',
|
|
100
102
|
// 'Optionally append a fenced JSON evidence block at the end if relevant.',
|
|
101
103
|
// 'If you output evidence, follow the exact evidence schema described.',
|
|
102
104
|
];
|
|
@@ -148,4 +150,9 @@ async function getJsonFromS3(bucket: string, key: string): Promise<any> {
|
|
|
148
150
|
export async function getReportGraphData(badgeId: string): Promise<GraphInsightsPayload | undefined> {
|
|
149
151
|
const badge = await doc.send(new GetCommand({ TableName: badgeTableName, Key: { badgeId } }));
|
|
150
152
|
return badge.Item?.assessmentResult?.graph_insights as GraphInsightsPayload | undefined;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export async function getBadgeUserId(badgeId: string): Promise<string> {
|
|
156
|
+
const badge = await doc.send(new GetCommand({ TableName: badgeTableName, Key: { badgeId } }));
|
|
157
|
+
return badge.Item?.userId as string;
|
|
151
158
|
}
|
package/src/lib/routes.ts
CHANGED
|
@@ -6,7 +6,13 @@ import { streamText } from 'ai';
|
|
|
6
6
|
import { bedrock } from '@ai-sdk/amazon-bedrock';
|
|
7
7
|
|
|
8
8
|
import { getHistory, putMessage } from './chat-store';
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
aggregateUserData,
|
|
11
|
+
cleanDeveloperProfile,
|
|
12
|
+
buildAllContextPrompt,
|
|
13
|
+
getReportGraphData,
|
|
14
|
+
getBadgeUserId
|
|
15
|
+
} from './context';
|
|
10
16
|
import { checkAndConsumeToken } from './rate-limit';
|
|
11
17
|
|
|
12
18
|
import { createSession } from './chat-store';
|
|
@@ -29,7 +35,8 @@ export async function chatStreamRoute(req: NextRequest, userId: string, companyI
|
|
|
29
35
|
|
|
30
36
|
await putMessage({ sessionId, role: 'user', content });
|
|
31
37
|
|
|
32
|
-
const
|
|
38
|
+
const badgeUserId = await getBadgeUserId(badgeId);
|
|
39
|
+
const aggregated = await aggregateUserData(badgeUserId, !!companyId, companyId);
|
|
33
40
|
const cleaned = cleanDeveloperProfile(aggregated);
|
|
34
41
|
const graphData = await getReportGraphData(badgeId);
|
|
35
42
|
const system = buildAllContextPrompt(cleaned, graphData, { concise: true });
|