@afncdelacru/brady-chat 0.1.0
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/dist/index.d.mts +82 -0
- package/dist/index.d.ts +82 -0
- package/dist/index.js +1405 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1374 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +34 -0
- package/src/index.ts +4 -0
- package/src/lib/BradyChatContext.tsx +203 -0
- package/src/lib/EnhancedBradyChat.tsx +590 -0
- package/src/lib/ImageWithFallback.tsx +28 -0
- package/src/lib/InfoRequestForm.tsx +115 -0
- package/src/lib/LeadershipCallForm.tsx +161 -0
- package/src/lib/ModePromptTree.tsx +277 -0
- package/src/lib/PersonalizedOverviewForm.tsx +132 -0
- package/src/lib/QuickSuggestions.tsx +33 -0
- package/src/lib/api/afnBradyApi.ts +48 -0
- package/src/lib/api/bradyHealth.ts +13 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { motion } from 'motion/react';
|
|
4
|
+
|
|
5
|
+
interface QuickSuggestion {
|
|
6
|
+
text: string;
|
|
7
|
+
action: () => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface QuickSuggestionsProps {
|
|
11
|
+
suggestions: QuickSuggestion[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function QuickSuggestions({ suggestions }: QuickSuggestionsProps) {
|
|
15
|
+
return (
|
|
16
|
+
<motion.div
|
|
17
|
+
initial={{ opacity: 0, y: 10 }}
|
|
18
|
+
animate={{ opacity: 1, y: 0 }}
|
|
19
|
+
className="flex flex-wrap gap-2"
|
|
20
|
+
>
|
|
21
|
+
{suggestions.map((suggestion, idx) => (
|
|
22
|
+
<button
|
|
23
|
+
key={idx}
|
|
24
|
+
onClick={suggestion.action}
|
|
25
|
+
className="px-3 py-1.5 bg-zinc-100 dark:bg-zinc-800 hover:bg-zinc-200 dark:hover:bg-zinc-700 text-zinc-700 dark:text-zinc-300 text-sm rounded-full border border-zinc-300 dark:border-zinc-700 transition-colors"
|
|
26
|
+
>
|
|
27
|
+
{suggestion.text}
|
|
28
|
+
</button>
|
|
29
|
+
))}
|
|
30
|
+
</motion.div>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// afnBradyApi.ts (library version)
|
|
2
|
+
// Utility for integrating with AFN Brady Jr API
|
|
3
|
+
|
|
4
|
+
const API_URL = 'https://afn-bradyjr-api-dev.azurewebsites.net/api/chat/prompt';
|
|
5
|
+
|
|
6
|
+
// NOTE: In this library copy we keep the default key as-is to preserve behavior
|
|
7
|
+
// for your existing app. Before publishing publicly, you should replace this
|
|
8
|
+
// with configuration (env variables or props) instead of bundling secrets.
|
|
9
|
+
export const DEFAULT_BRADY_API_KEY =
|
|
10
|
+
'za2345DDDzXycXKHJvVj80TIsPgooB7iNbwcS9KLzoeaOljlXmJQQJ99BJAC4f1cMXJ3w3AAAAACOGQzXz';
|
|
11
|
+
|
|
12
|
+
export interface BradyMessage {
|
|
13
|
+
role: 'user' | 'assistant' | 'system';
|
|
14
|
+
content: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface BradyChatRequest {
|
|
18
|
+
messages: BradyMessage[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface BradyChatResponse {
|
|
22
|
+
role: string;
|
|
23
|
+
type: string;
|
|
24
|
+
content: string;
|
|
25
|
+
suggestionLink?: { text: string; prompt: string }[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function sendBradyPrompt(
|
|
29
|
+
messages: BradyMessage[],
|
|
30
|
+
apiKey: string = DEFAULT_BRADY_API_KEY
|
|
31
|
+
): Promise<BradyChatResponse> {
|
|
32
|
+
const res = await fetch(API_URL, {
|
|
33
|
+
method: 'POST',
|
|
34
|
+
headers: {
|
|
35
|
+
'Content-Type': 'application/json',
|
|
36
|
+
'X-API-KEY': apiKey
|
|
37
|
+
},
|
|
38
|
+
body: JSON.stringify({ messages })
|
|
39
|
+
});
|
|
40
|
+
if (!res.ok) throw new Error('Brady API error: ' + res.status);
|
|
41
|
+
const data = await res.json();
|
|
42
|
+
if (process.env.NODE_ENV === 'development') {
|
|
43
|
+
// eslint-disable-next-line no-console
|
|
44
|
+
console.log('[Brady API Response]', data);
|
|
45
|
+
}
|
|
46
|
+
return data;
|
|
47
|
+
}
|
|
48
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// bradyHealth.ts (library version)
|
|
2
|
+
// Utility to check health of Brady AI API
|
|
3
|
+
|
|
4
|
+
export async function checkBradyHealth(): Promise<boolean> {
|
|
5
|
+
try {
|
|
6
|
+
const res = await fetch('https://afn-bradyjr-api-dev.azurewebsites.net/api/Health');
|
|
7
|
+
if (!res.ok) return false;
|
|
8
|
+
return true;
|
|
9
|
+
} catch {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "./dist",
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": true,
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"moduleResolution": "bundler",
|
|
10
|
+
"module": "ESNext",
|
|
11
|
+
"target": "ESNext",
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"allowSyntheticDefaultImports": true,
|
|
14
|
+
"esModuleInterop": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["src"]
|
|
17
|
+
}
|