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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kyd-shared-badge",
3
- "version": "0.3.13",
3
+ "version": "0.3.15",
4
4
  "private": false,
5
5
  "main": "./src/index.ts",
6
6
  "module": "./src/index.ts",
@@ -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 { aggregateUserData, cleanDeveloperProfile, buildAllContextPrompt, getReportGraphData } from './context';
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 aggregated = await aggregateUserData(userId, !!companyId, companyId);
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 });