rishabh5752 commited on
Commit
b3244f5
·
verified ·
1 Parent(s): 1ab9085

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
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
- from openai import OpenAI
6
 
7
- # --------------- Setup OpenAI Client ---------------
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("[GPT-5-nano] Prompt:", prompt)
63
- response = client.responses.create(
64
- model="gpt-5-nano",
65
- input=prompt
 
 
 
 
 
66
  )
67
- out = response.output_text.strip()
68
- print("[GPT-5-nano] Raw output:", out)
69
  if len(out) > 20:
70
  return out
71
  except Exception as e:
72
- print("[GPT-5-nano] ERROR:", e)
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