designfailure commited on
Commit
eb9b2b9
1 Parent(s): 954f0a5

Upload 22 files

Browse files
.gitignore ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+ pnpm-debug.log*
8
+ lerna-debug.log*
9
+
10
+ node_modules
11
+ dist
12
+ dist-ssr
13
+ *.local
14
+
15
+ # Editor directories and files
16
+ .vscode/*
17
+ !.vscode/extensions.json
18
+ .idea
19
+ .DS_Store
20
+ *.suo
21
+ *.ntvs*
22
+ *.njsproj
23
+ *.sln
24
+ *.sw?
AgentCard.tsx ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+ import { AgentConfig } from '../types/Agent';
3
+
4
+ interface AgentCardProps {
5
+ config: AgentConfig;
6
+ status: 'idle' | 'processing' | 'complete';
7
+ }
8
+
9
+ export function AgentCard({ config, status }: AgentCardProps) {
10
+ return (
11
+ <div className="bg-white rounded-lg shadow p-4 mb-4">
12
+ <h3 className="text-lg font-semibold">{config.name}</h3>
13
+ <p className="text-sm text-gray-600 mb-2">{config.goal}</p>
14
+ <div className="flex items-center">
15
+ <span className={`w-2 h-2 rounded-full mr-2 ${
16
+ status === 'idle' ? 'bg-gray-400' :
17
+ status === 'processing' ? 'bg-blue-500' :
18
+ 'bg-green-500'
19
+ }`} />
20
+ <span className="text-sm capitalize">{status}</span>
21
+ </div>
22
+ </div>
23
+ );
24
+ }
App.tsx ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+ import GradioInterface from './ui/GradioInterface';
3
+
4
+ function App() {
5
+ return (
6
+ <div className="min-h-screen bg-gray-100">
7
+ <header className="bg-white shadow-sm">
8
+ <div className="container mx-auto px-4 py-4">
9
+ <h1 className="text-2xl font-bold text-gray-900">
10
+ InsurTech Agentic Workflow System
11
+ </h1>
12
+ </div>
13
+ </header>
14
+ <main>
15
+ <GradioInterface />
16
+ </main>
17
+ </div>
18
+ );
19
+ }
20
+
21
+ export default App;
ChatMessage.tsx ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+
3
+ interface ChatMessageProps {
4
+ message: string;
5
+ sender: 'user' | 'agent';
6
+ timestamp: Date;
7
+ }
8
+
9
+ export function ChatMessage({ message, sender, timestamp }: ChatMessageProps) {
10
+ return (
11
+ <div className={`flex ${sender === 'user' ? 'justify-end' : 'justify-start'} mb-4`}>
12
+ <div className={`max-w-[70%] rounded-lg p-3 ${
13
+ sender === 'user' ? 'bg-blue-500 text-white' : 'bg-gray-100'
14
+ }`}>
15
+ <p className="text-sm">{message}</p>
16
+ <span className="text-xs text-gray-500 mt-1">
17
+ {timestamp.toLocaleTimeString()}
18
+ </span>
19
+ </div>
20
+ </div>
21
+ );
22
+ }
ESGCompliance.ts ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Agent } from 'crewai';
2
+ import axios from 'axios';
3
+
4
+ export class ESGCompliance extends Agent {
5
+ constructor() {
6
+ super({
7
+ name: 'ESG Compliance Analyst',
8
+ goal: 'Assess ESG and carbon risk compliance',
9
+ backstory: 'Expert ESG analyst focused on environmental impact assessment',
10
+ });
11
+ }
12
+
13
+ async assessESGRisk(data: any) {
14
+ const [weatherData, carbonData] = await Promise.all([
15
+ this.getWeatherData(data.location),
16
+ this.getCarbonEstimate(data)
17
+ ]);
18
+
19
+ return {
20
+ esgScore: this.calculateESGScore(data),
21
+ carbonRisk: this.assessCarbonRisk(carbonData),
22
+ climateImpact: this.assessClimateImpact(weatherData)
23
+ };
24
+ }
25
+
26
+ private async getWeatherData(location: string) {
27
+ // Weather API integration
28
+ }
29
+
30
+ private async getCarbonEstimate(data: any) {
31
+ // Climatiq API integration
32
+ }
33
+
34
+ private calculateESGScore(data: any) {
35
+ // ESG scoring logic
36
+ }
37
+ }
GradioInterface.tsx ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState } from 'react';
2
+ import { Upload, MessageSquare } from 'lucide-react';
3
+ import { AgentCard } from '../components/AgentCard';
4
+ import { ChatMessage } from '../components/ChatMessage';
5
+ import { processFile } from '../utils/fileProcessing';
6
+
7
+ interface Message {
8
+ content: string;
9
+ sender: 'user' | 'agent';
10
+ timestamp: Date;
11
+ }
12
+
13
+ export default function GradioInterface() {
14
+ const [messages, setMessages] = useState<Message[]>([]);
15
+ const [inputText, setInputText] = useState('');
16
+ const [agents] = useState([
17
+ {
18
+ config: {
19
+ name: 'MGA Analyst',
20
+ goal: 'Analyze insurance queries and delegate tasks',
21
+ backstory: 'Expert executive-director agent'
22
+ },
23
+ status: 'idle' as const
24
+ },
25
+ {
26
+ config: {
27
+ name: 'Underwriter',
28
+ goal: 'Evaluate risks and recommend policies',
29
+ backstory: 'Expert risk assessor'
30
+ },
31
+ status: 'idle' as const
32
+ }
33
+ ]);
34
+
35
+ const handleFileUpload = async (event: React.ChangeEvent<HTMLInputElement>) => {
36
+ const file = event.target.files?.[0];
37
+ if (file) {
38
+ const processedFile = await processFile(file);
39
+ setMessages(prev => [...prev, {
40
+ content: `File uploaded: ${file.name}`,
41
+ sender: 'user',
42
+ timestamp: new Date()
43
+ }]);
44
+ }
45
+ };
46
+
47
+ const handleSendMessage = () => {
48
+ if (inputText.trim()) {
49
+ setMessages(prev => [...prev, {
50
+ content: inputText,
51
+ sender: 'user',
52
+ timestamp: new Date()
53
+ }]);
54
+ setInputText('');
55
+ }
56
+ };
57
+
58
+ return (
59
+ <div className="min-h-screen bg-gray-50">
60
+ <div className="container mx-auto px-4 py-8">
61
+ <div className="grid grid-cols-12 gap-6">
62
+ <div className="col-span-8 bg-white rounded-lg shadow-lg p-6">
63
+ <div className="flex flex-col h-[600px]">
64
+ <div className="flex-1 overflow-y-auto mb-4">
65
+ {messages.map((msg, idx) => (
66
+ <ChatMessage key={idx} {...msg} />
67
+ ))}
68
+ </div>
69
+ <div className="flex gap-4">
70
+ <label className="flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg cursor-pointer">
71
+ <Upload className="w-5 h-5 mr-2" />
72
+ Upload File
73
+ <input
74
+ type="file"
75
+ className="hidden"
76
+ onChange={handleFileUpload}
77
+ accept=".csv,.xls,.doc,.pdf"
78
+ />
79
+ </label>
80
+ <input
81
+ type="text"
82
+ value={inputText}
83
+ onChange={(e) => setInputText(e.target.value)}
84
+ className="flex-1 px-4 py-2 border rounded-lg"
85
+ placeholder="Type your message..."
86
+ onKeyPress={(e) => e.key === 'Enter' && handleSendMessage()}
87
+ />
88
+ <button
89
+ onClick={handleSendMessage}
90
+ className="flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg"
91
+ >
92
+ <MessageSquare className="w-5 h-5 mr-2" />
93
+ Send
94
+ </button>
95
+ </div>
96
+ </div>
97
+ </div>
98
+
99
+ <div className="col-span-4 bg-white rounded-lg shadow-lg p-6">
100
+ <h2 className="text-xl font-bold mb-4">Agent Status</h2>
101
+ {agents.map((agent, idx) => (
102
+ <AgentCard key={idx} {...agent} />
103
+ ))}
104
+ </div>
105
+ </div>
106
+ </div>
107
+ </div>
108
+ );
109
+ }
MGAAnalyst.ts ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Agent } from 'crewai';
2
+
3
+ export class MGAAnalyst extends Agent {
4
+ constructor() {
5
+ super({
6
+ name: 'MGA Analyst',
7
+ goal: 'Analyze insurance queries and delegate tasks to specialized agents',
8
+ backstory: 'Expert executive-director agent focused on risk assessment and revenue optimization',
9
+ });
10
+ }
11
+
12
+ async analyzeInput(input: string | File) {
13
+ // Implement input analysis logic
14
+ const analysis = {
15
+ riskCategory: this.categorizeRisk(input),
16
+ delegationPlan: this.createDelegationPlan(),
17
+ preventionStrategy: this.generatePreventionStrategy()
18
+ };
19
+
20
+ return analysis;
21
+ }
22
+
23
+ private categorizeRisk(input: any) {
24
+ // Risk categorization logic
25
+ }
26
+
27
+ private createDelegationPlan() {
28
+ // Task delegation logic
29
+ }
30
+
31
+ private generatePreventionStrategy() {
32
+ // Prevention strategy generation
33
+ }
34
+ }
PolicyManager.ts ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Agent } from 'crewai';
2
+
3
+ export class PolicyManager extends Agent {
4
+ constructor() {
5
+ super({
6
+ name: 'Policy Manager',
7
+ goal: 'Manage policy administration and claims handling',
8
+ backstory: 'Expert policy handler focused on customer satisfaction',
9
+ });
10
+ }
11
+
12
+ async handlePolicy(policyData: any) {
13
+ return {
14
+ coverage: this.defineCoverage(policyData),
15
+ terms: this.defineTerms(policyData),
16
+ exclusions: this.defineExclusions(policyData)
17
+ };
18
+ }
19
+
20
+ private defineCoverage(data: any) {
21
+ // Coverage definition logic
22
+ }
23
+
24
+ private defineTerms(data: any) {
25
+ // Terms definition logic
26
+ }
27
+
28
+ private defineExclusions(data: any) {
29
+ // Exclusions definition logic
30
+ }
31
+ }
RiskExposure.ts ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Agent } from 'crewai';
2
+
3
+ export class RiskExposure extends Agent {
4
+ constructor() {
5
+ super({
6
+ name: 'Risk Exposure Analyst',
7
+ goal: 'Assess and quantify portfolio risk exposure',
8
+ backstory: 'Expert risk analyst focused on portfolio risk management',
9
+ });
10
+ }
11
+
12
+ async assessRiskExposure(portfolio: any) {
13
+ return {
14
+ exposureMetrics: this.calculateExposureMetrics(portfolio),
15
+ riskFactors: this.identifyRiskFactors(portfolio),
16
+ mitigationStrategies: this.developMitigationStrategies(portfolio)
17
+ };
18
+ }
19
+
20
+ private calculateExposureMetrics(data: any) {
21
+ // Exposure calculation logic
22
+ }
23
+
24
+ private identifyRiskFactors(data: any) {
25
+ // Risk factor identification logic
26
+ }
27
+
28
+ private developMitigationStrategies(data: any) {
29
+ // Mitigation strategy development logic
30
+ }
31
+ }
Underwriter.ts ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Agent } from 'crewai';
2
+
3
+ export class Underwriter extends Agent {
4
+ constructor() {
5
+ super({
6
+ name: 'Underwriter',
7
+ goal: 'Evaluate risks and recommend appropriate policies',
8
+ backstory: 'Expert underwriter focused on risk assessment and policy recommendations',
9
+ });
10
+ }
11
+
12
+ async evaluateRisk(data: any) {
13
+ // Risk evaluation logic
14
+ return {
15
+ riskScore: this.calculateRiskScore(data),
16
+ recommendedPolicies: this.generatePolicyRecommendations(data),
17
+ fraudRisk: this.assessFraudRisk(data)
18
+ };
19
+ }
20
+
21
+ private calculateRiskScore(data: any) {
22
+ // Risk scoring logic
23
+ }
24
+
25
+ private generatePolicyRecommendations(data: any) {
26
+ // Policy recommendation logic
27
+ }
28
+
29
+ private assessFraudRisk(data: any) {
30
+ // Fraud risk assessment logic
31
+ }
32
+ }
eslint.config.js ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import js from '@eslint/js';
2
+ import globals from 'globals';
3
+ import reactHooks from 'eslint-plugin-react-hooks';
4
+ import reactRefresh from 'eslint-plugin-react-refresh';
5
+ import tseslint from 'typescript-eslint';
6
+
7
+ export default tseslint.config(
8
+ { ignores: ['dist'] },
9
+ {
10
+ extends: [js.configs.recommended, ...tseslint.configs.recommended],
11
+ files: ['**/*.{ts,tsx}'],
12
+ languageOptions: {
13
+ ecmaVersion: 2020,
14
+ globals: globals.browser,
15
+ },
16
+ plugins: {
17
+ 'react-hooks': reactHooks,
18
+ 'react-refresh': reactRefresh,
19
+ },
20
+ rules: {
21
+ ...reactHooks.configs.recommended.rules,
22
+ 'react-refresh/only-export-components': [
23
+ 'warn',
24
+ { allowConstantExport: true },
25
+ ],
26
+ },
27
+ }
28
+ );
index.css ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
index.html ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Vite + React + TS</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>
main.tsx ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import { StrictMode } from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
+ import App from './App.tsx';
4
+ import './index.css';
5
+
6
+ createRoot(document.getElementById('root')!).render(
7
+ <StrictMode>
8
+ <App />
9
+ </StrictMode>
10
+ );
package-lock.json ADDED
The diff for this file is too large to render. See raw diff
 
package.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "insurtech-agentic-system",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc && vite build",
9
+ "lint": "eslint .",
10
+ "preview": "vite preview"
11
+ },
12
+ "dependencies": {
13
+ "lucide-react": "^0.344.0",
14
+ "react": "^18.3.1",
15
+ "react-dom": "^18.3.1",
16
+ "axios": "^1.6.7",
17
+ "crewai": "^1.0.0"
18
+ },
19
+ "devDependencies": {
20
+ "@eslint/js": "^9.9.1",
21
+ "@types/react": "^18.3.5",
22
+ "@types/react-dom": "^18.3.0",
23
+ "@vitejs/plugin-react": "^4.3.1",
24
+ "autoprefixer": "^10.4.18",
25
+ "eslint": "^9.9.1",
26
+ "eslint-plugin-react-hooks": "^5.1.0-rc.0",
27
+ "eslint-plugin-react-refresh": "^0.4.11",
28
+ "globals": "^15.9.0",
29
+ "postcss": "^8.4.35",
30
+ "tailwindcss": "^3.4.1",
31
+ "typescript": "^5.5.3",
32
+ "typescript-eslint": "^8.3.0",
33
+ "vite": "^5.4.2"
34
+ }
35
+ }
postcss.config.js ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ export default {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ };
tailwind.config.js ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ /** @type {import('tailwindcss').Config} */
2
+ export default {
3
+ content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
4
+ theme: {
5
+ extend: {},
6
+ },
7
+ plugins: [],
8
+ };
tsconfig.app.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
+ "module": "ESNext",
7
+ "skipLibCheck": true,
8
+
9
+ /* Bundler mode */
10
+ "moduleResolution": "bundler",
11
+ "allowImportingTsExtensions": true,
12
+ "isolatedModules": true,
13
+ "moduleDetection": "force",
14
+ "noEmit": true,
15
+ "jsx": "react-jsx",
16
+
17
+ /* Linting */
18
+ "strict": true,
19
+ "noUnusedLocals": true,
20
+ "noUnusedParameters": true,
21
+ "noFallthroughCasesInSwitch": true
22
+ },
23
+ "include": ["src"]
24
+ }
tsconfig.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "files": [],
3
+ "references": [
4
+ { "path": "./tsconfig.app.json" },
5
+ { "path": "./tsconfig.node.json" }
6
+ ]
7
+ }
tsconfig.node.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": ["ES2023"],
5
+ "module": "ESNext",
6
+ "skipLibCheck": true,
7
+
8
+ /* Bundler mode */
9
+ "moduleResolution": "bundler",
10
+ "allowImportingTsExtensions": true,
11
+ "isolatedModules": true,
12
+ "moduleDetection": "force",
13
+ "noEmit": true,
14
+
15
+ /* Linting */
16
+ "strict": true,
17
+ "noUnusedLocals": true,
18
+ "noUnusedParameters": true,
19
+ "noFallthroughCasesInSwitch": true
20
+ },
21
+ "include": ["vite.config.ts"]
22
+ }
vite.config.ts ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import { defineConfig } from 'vite';
2
+ import react from '@vitejs/plugin-react';
3
+
4
+ // https://vitejs.dev/config/
5
+ export default defineConfig({
6
+ plugins: [react()],
7
+ optimizeDeps: {
8
+ exclude: ['lucide-react'],
9
+ },
10
+ });