bpmredacademy commited on
Commit
ed1bd98
·
verified ·
1 Parent(s): a0b8ed4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -1
app.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import gradio as gr
2
  from datetime import datetime
3
  import json
@@ -5,6 +7,8 @@ import uuid
5
 
6
  APP_TITLE = "HumAI Midfielder Avatar"
7
  APP_VERSION = "v0.2.0-enterprise-demo"
 
 
8
  LIVE_PRODUCT_URL = "https://humai-orchestration-makerfire.vercel.app"
9
  BRAND_LAYER = "BPM RED Academy / MightHub HumAI Layer"
10
  PRODUCT_NAME = "HumAI Midfielder Avatar"
@@ -56,6 +60,68 @@ def normalize_selection(value, mapping, fallback):
56
  def clamp(value, min_value=0.52, max_value=0.96):
57
  return max(min_value, min(max_value, value))
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
  def build_avatar_intro(domain_label, mode_label, scenario_label, priority):
61
  return (
@@ -72,6 +138,7 @@ def build_avatar_intro(domain_label, mode_label, scenario_label, priority):
72
  def evaluate_mission_control(domain, mode, scenario, priority, user_context):
73
  risk = "MEDIUM"
74
  score = 0.72
 
75
  recommendation = "Use structured Human-AI orchestration before taking operational action."
76
  explanation = (
77
  "HumAI structures the situation, evaluates domain context and prepares "
@@ -293,7 +360,9 @@ def evaluate_mission_control(domain, mode, scenario, priority, user_context):
293
  "doa_layer": DOA_FULL_NAME,
294
  "version": APP_VERSION,
295
  "execution_mode": "deterministic_enterprise_fallback",
296
- "ai_assisted": False,
 
 
297
  "domain": domain,
298
  "mode": mode,
299
  "scenario": scenario,
 
1
+ import requests
2
+ import os
3
  import gradio as gr
4
  from datetime import datetime
5
  import json
 
7
 
8
  APP_TITLE = "HumAI Midfielder Avatar"
9
  APP_VERSION = "v0.2.0-enterprise-demo"
10
+ INFERENCE_URL = os.getenv("INFERENCE_URL", "")
11
+ INFERENCE_API_KEY = os.getenv("INFERENCE_API_KEY", "")
12
  LIVE_PRODUCT_URL = "https://humai-orchestration-makerfire.vercel.app"
13
  BRAND_LAYER = "BPM RED Academy / MightHub HumAI Layer"
14
  PRODUCT_NAME = "HumAI Midfielder Avatar"
 
60
  def clamp(value, min_value=0.52, max_value=0.96):
61
  return max(min_value, min(max_value, value))
62
 
63
+ def call_real_inference(prompt):
64
+
65
+ if not INFERENCE_URL:
66
+ return {
67
+ "success": False,
68
+ "fallback": True,
69
+ "content": "Inference endpoint not configured."
70
+ }
71
+
72
+ headers = {
73
+ "Authorization": f"Bearer {INFERENCE_API_KEY}",
74
+ "Content-Type": "application/json"
75
+ }
76
+
77
+ payload = {
78
+ "model": "FinC2E",
79
+ "messages": [
80
+ {
81
+ "role": "system",
82
+ "content": "You are FinC2E governance runtime."
83
+ },
84
+ {
85
+ "role": "user",
86
+ "content": prompt
87
+ }
88
+ ],
89
+ "temperature": 0.1,
90
+ "max_tokens": 400
91
+ }
92
+
93
+ try:
94
+
95
+ response = requests.post(
96
+ INFERENCE_URL,
97
+ headers=headers,
98
+ json=payload,
99
+ timeout=60
100
+ )
101
+
102
+ data = response.json()
103
+
104
+ content = (
105
+ data.get("choices", [{}])[0]
106
+ .get("message", {})
107
+ .get("content", "")
108
+ )
109
+
110
+ return {
111
+ "success": True,
112
+ "fallback": False,
113
+ "content": content,
114
+ "raw": data
115
+ }
116
+
117
+ except Exception as e:
118
+
119
+ return {
120
+ "success": False,
121
+ "fallback": True,
122
+ "content": str(e)
123
+ }
124
+
125
 
126
  def build_avatar_intro(domain_label, mode_label, scenario_label, priority):
127
  return (
 
138
  def evaluate_mission_control(domain, mode, scenario, priority, user_context):
139
  risk = "MEDIUM"
140
  score = 0.72
141
+ real_runtime = call_real_inference(user_context)
142
  recommendation = "Use structured Human-AI orchestration before taking operational action."
143
  explanation = (
144
  "HumAI structures the situation, evaluates domain context and prepares "
 
360
  "doa_layer": DOA_FULL_NAME,
361
  "version": APP_VERSION,
362
  "execution_mode": "deterministic_enterprise_fallback",
363
+ "ai_assisted": real_runtime["success"],
364
+ "inference_fallback": real_runtime["fallback"],
365
+ "runtime_output": real_runtime["content"],
366
  "domain": domain,
367
  "mode": mode,
368
  "scenario": scenario,