kyd-shared-badge 0.3.54 → 0.3.56

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.54",
3
+ "version": "0.3.56",
4
4
  "private": false,
5
5
  "main": "./src/index.ts",
6
6
  "module": "./src/index.ts",
@@ -9,10 +9,10 @@ import { FiInfo, FiAlertTriangle } from 'react-icons/fi';
9
9
  // Register English locale once at module import time
10
10
  countriesLib.registerLocale(enLocale);
11
11
 
12
- export const getBadgeImageUrl = (score: number) => {
13
- if (score >= 75) return '/badgegreen2.png';
14
- if (score >= 50) return '/badgeyellow2.png';
15
- return '/badgered2.png';
12
+ export const getBadgeImageUrl = (score: number, bland: boolean = false) => {
13
+ if (score >= 75) return bland ? 'badgegreensimple.png' : '/badgegreen2.png';
14
+ if (score >= 50) return bland ? 'badgeyellowsimple.png' : '/badgeyellow2.png';
15
+ return bland ? 'badgeredsimple.png' : '/badgered2.png';
16
16
  };
17
17
 
18
18
  const hexToRgba = (hex: string, alpha: number) => {
package/src/lib/routes.ts CHANGED
@@ -42,9 +42,9 @@ export async function chatStreamRoute(req: NextRequest, userId: string, companyI
42
42
  const graphData = await getReportGraphData(badgeId);
43
43
  const system = buildAllContextPrompt(cleaned, graphData, { concise: true });
44
44
  const history = await getHistory(sessionId, 20);
45
- const apiKey = process.env.OPENROUTER_API_KEY;
45
+ const apiKey = process.env.OPENAI_API_KEY;
46
46
  if (!apiKey) {
47
- return Response.json({ error: 'Server misconfigured: missing OPENROUTER_API_KEY' }, { status: 500 });
47
+ return Response.json({ error: 'Server misconfigured: missing OPENAI_API_KEY' }, { status: 500 });
48
48
  }
49
49
 
50
50
  const chatMessages = [
@@ -53,24 +53,21 @@ export async function chatStreamRoute(req: NextRequest, userId: string, companyI
53
53
  { role: 'user', content },
54
54
  ];
55
55
 
56
- const openai = createOpenAI({
57
- apiKey,
58
- baseURL: 'https://openrouter.ai/api/v1',
59
- });
56
+ const openai = createOpenAI({ apiKey });
60
57
 
61
58
  const result = await streamText({
62
- model: openai('openai/o4-mini'),
59
+ model: openai('gpt-4o-mini'),
63
60
  messages: chatMessages as any,
64
61
  maxTokens: 1024,
62
+ onFinish: async ({ text }: { text: string }) => {
63
+ try { if (text) await putMessage({ sessionId, role: 'assistant', content: text }); } catch {}
64
+ },
65
65
  });
66
66
 
67
- return result.toAIStreamResponse({
67
+ return result.toTextStreamResponse({
68
68
  headers: {
69
69
  'X-Accel-Buffering': 'no',
70
70
  },
71
- onFinal: async (finalText: string) => {
72
- try { if (finalText) await putMessage({ sessionId, role: 'assistant', content: finalText }); } catch {}
73
- },
74
71
  });
75
72
 
76
73
  } catch (e) {