File tree Expand file tree Collapse file tree 4 files changed +110
-3
lines changed
dagger/src/fraud_simulation Expand file tree Collapse file tree 4 files changed +110
-3
lines changed Original file line number Diff line number Diff line change 2121 GROQ_API_KEY : ${{ secrets.GROQ_API_KEY }}
2222 DAGGER_CLOUD_TOKEN : ${{ secrets.DAGGER_CLOUD_TOKEN }}
2323 run : |
24- dagger call run-fraud-sim --source . --gemini-api-key env:GEMINI_API_KEY --groq-api-key env:GROQ_API_KEY
24+ mkdir -p fraud_simulation_reports
25+ dagger call run-fraud-sim --source . --gemini-api-key env:GEMINI_API_KEY --groq-api-key env:GROQ_API_KEY export --path fraud_simulation_reports/summary.json
26+
27+ - name : Upload Simulation Summary
28+ uses : actions/upload-artifact@v4
29+ with :
30+ name : fraud-summary
31+ path : fraud_simulation_reports/summary.json
Original file line number Diff line number Diff line change 1+ name : Deploy Fraud Dashboard
2+
3+ on :
4+ workflow_run :
5+ workflows : ["Dagger Fraud Simulation"]
6+ types :
7+ - completed
8+ workflow_dispatch :
9+
10+ permissions :
11+ actions : read
12+ contents : write
13+
14+ jobs :
15+ update-dashboard :
16+ runs-on : ubuntu-latest
17+ if : ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
18+ steps :
19+ - uses : actions/checkout@v3
20+
21+ - name : Download Simulation Summary
22+ uses : actions/download-artifact@v4
23+ with :
24+ name : fraud-summary
25+ path : fraud_simulation_reports
26+ run-id : ${{ github.event.workflow_run.id }}
27+ github-token : ${{ secrets.AUTHENTICATION_SERVICE_GITHUB_TOKEN }}
28+
29+ - name : Install Dagger CLI
30+ uses : dagger/dagger-for-github@v7
31+ with :
32+ version : " 0.19.8"
33+ install-only : true
34+
35+ - name : Copy Dagger results to dashboard
36+ run : |
37+ mkdir -p dashboard
38+ mv fraud_simulation_reports/summary.json dashboard/summary.json
39+
40+ - name : Run AI Agent Summary
41+ env :
42+ GEMINI_API_KEY : ${{ secrets.GEMINI_API_KEY }}
43+ run : |
44+ echo "Generating fraud summary insights via AI Agent"
45+ dagger call analyze-results --summary dashboard/summary.json > dashboard/insights.txt
46+
47+ - name : Commit and push
48+ run : |
49+ git config user.name "github-actions"
50+ git config user.email "github-actions@github.com"
51+ git add dashboard/
52+ git commit -m "Update fraud dashboard with AI insights"
53+ git push
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ async def run_fraud_sim(
99 source : dagger .Directory ,
1010 gemini_api_key : dagger .Secret ,
1111 groq_api_key : dagger .Secret ,
12- ) -> str :
12+ ) -> dagger . File :
1313 """
1414 Runs the fraud simulation using the global Dagger context.
1515 """
@@ -43,4 +43,23 @@ async def run_fraud_sim(
4343 # Force streaming stdout to trigger execution
4444 await step3 .stdout ()
4545
46- return "✅ Simulation complete! Results available in fraud_simulation_reports/summary.json"
46+ return step3 .file ("fraud_simulation_reports/iteration_latest.json" )
47+
48+ @function
49+ async def analyze_results (self , summary : dagger .File ) -> str :
50+ return (
51+ dag .llm ()
52+ .with_env (
53+ dag .env ()
54+ .with_file_input ("summary" , summary )
55+ .with_string_output ("insights" )
56+ )
57+ .with_prompt ("""
58+ Review this fraud summary:
59+ $summary
60+
61+ Identify top suspicious accounts and patterns. Suggest any actions or remediations.
62+ Highlight any unusual spikes or risk factors.
63+ """ )
64+ .env ().output ("insights" ).as_string ()
65+ )
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < title > Fraud Simulation Report</ title >
5+ < style >
6+ body { font-family : sans-serif; padding : 1rem ; }
7+ pre { background : # f5f5f5 ; padding : 1rem ; overflow-x : auto; }
8+ </ style >
9+ </ head >
10+ < body >
11+ < h1 > Fraud Simulation Report</ h1 >
12+ < pre id ="output "> Loading summary...</ pre >
13+ < h2 > AI Insights</ h2 >
14+ < pre id ="insights "> Loading insights...</ pre >
15+ < script >
16+ fetch ( 'summary.json' )
17+ . then ( res => res . json ( ) )
18+ . then ( data => {
19+ document . getElementById ( 'output' ) . textContent = JSON . stringify ( data , null , 2 ) ;
20+ } ) ;
21+ fetch ( 'insights.txt' )
22+ . then ( res => res . text ( ) )
23+ . then ( data => {
24+ document . getElementById ( 'insights' ) . textContent = data ;
25+ } ) ;
26+ </ script >
27+ </ body >
28+ </ html >
You can’t perform that action at this time.
0 commit comments