Update app.py
Browse files
app.py
CHANGED
|
@@ -2,10 +2,9 @@ import datetime, tempfile, traceback
|
|
| 2 |
import gradio as gr
|
| 3 |
import pandas as pd
|
| 4 |
from fpdf import FPDF
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
| 8 |
-
client = OpenAI(api_key="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")
|
| 9 |
|
| 10 |
QUESTIONS = [
|
| 11 |
"Governance framework is documented and communicated across the organisation.",
|
|
@@ -59,17 +58,22 @@ def llm_remediation(product, b_avgs, overall_tier):
|
|
| 59 |
"First, write a one-sentence overall assessment. Then, provide 3-5 markdown bullets suggesting next actions for improvement, mentioning bucket names."
|
| 60 |
)
|
| 61 |
try:
|
| 62 |
-
print("[
|
| 63 |
-
response =
|
| 64 |
-
model="gpt-5-nano"
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
)
|
| 67 |
-
out = response.
|
| 68 |
-
print("[
|
| 69 |
if len(out) > 20:
|
| 70 |
return out
|
| 71 |
except Exception as e:
|
| 72 |
-
print("[
|
| 73 |
traceback.print_exc()
|
| 74 |
|
| 75 |
# Rule-based fallback if OpenAI call fails
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
import pandas as pd
|
| 4 |
from fpdf import FPDF
|
| 5 |
+
import openai
|
| 6 |
|
| 7 |
+
openai.api_key = "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"
|
|
|
|
| 8 |
|
| 9 |
QUESTIONS = [
|
| 10 |
"Governance framework is documented and communicated across the organisation.",
|
|
|
|
| 58 |
"First, write a one-sentence overall assessment. Then, provide 3-5 markdown bullets suggesting next actions for improvement, mentioning bucket names."
|
| 59 |
)
|
| 60 |
try:
|
| 61 |
+
print("[OpenAI] Prompt:", prompt)
|
| 62 |
+
response = openai.ChatCompletion.create(
|
| 63 |
+
model="gpt-4o", # "gpt-5-nano" when available
|
| 64 |
+
messages=[
|
| 65 |
+
{"role": "system", "content": "You are an expert in AI governance maturity."},
|
| 66 |
+
{"role": "user", "content": prompt}
|
| 67 |
+
],
|
| 68 |
+
max_tokens=200,
|
| 69 |
+
temperature=0.3,
|
| 70 |
)
|
| 71 |
+
out = response["choices"][0]["message"]["content"].strip()
|
| 72 |
+
print("[OpenAI] Raw output:", out)
|
| 73 |
if len(out) > 20:
|
| 74 |
return out
|
| 75 |
except Exception as e:
|
| 76 |
+
print("[OpenAI] ERROR:", e)
|
| 77 |
traceback.print_exc()
|
| 78 |
|
| 79 |
# Rule-based fallback if OpenAI call fails
|