kgauvin603 commited on
Commit
802e708
·
verified ·
1 Parent(s): c0308e1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -13,6 +13,9 @@ if not openai_api_key:
13
 
14
  client = openai.OpenAI(api_key=openai_api_key)
15
 
 
 
 
16
  # --- Exadata Specs ---
17
  exadata_specs = {
18
  "X7": {"Quarter Rack": {"max_iops": 350000, "max_throughput": 25}, "Half Rack": {"max_iops": 700000, "max_throughput": 50}, "Full Rack": {"max_iops": 1400000, "max_throughput": 100}},
@@ -128,7 +131,7 @@ AWR CONTENT:
128
  """
129
 
130
  response = client.chat.completions.create(
131
- model="gpt-4-turbo",
132
  messages=[
133
  {"role": "system", "content": "You are the strict Oracle AWR Health Analysis Agent."},
134
  {"role": "user", "content": prompt}
@@ -137,16 +140,18 @@ AWR CONTENT:
137
 
138
  return response.choices[0].message.content.strip()
139
 
140
-
141
  class RaterAgent:
142
- def rate(self, content, llm_model):
143
  prompt = f"Rate the following analysis from 1-5 stars and explain:\n\n{content}"
144
- response = client.chat.completions.create(
145
- model=llm_model,
 
146
  messages=[{"role": "user", "content": prompt}]
147
  )
 
148
  return response.choices[0].message.content.strip()
149
 
 
150
  # === Main Process ===
151
  def process_awr(awr_text, threshold, performance_test_mode, exadata_model, rack_size, llm_model):
152
  analyzer = CriticalAnalyzerAgent()
@@ -158,7 +163,7 @@ def process_awr(awr_text, threshold, performance_test_mode, exadata_model, rack_
158
 
159
  analysis = analyzer.analyze(awr_text, performance_test_mode, exadata_model, rack_size, llm_model)
160
  health_status = health.check_health(awr_text, llm_model)
161
- rating_text = rater.rate(analysis, llm_model)
162
 
163
  stars = 0
164
  match = re.search(r"(\d+)", rating_text)
 
13
 
14
  client = openai.OpenAI(api_key=openai_api_key)
15
 
16
+ openrouter_key = os.environ.get("OPENROUTER")
17
+ openrouter = openai.OpenAI(api_key=openrouter_key, base_url="https://openrouter.ai/api/v1")
18
+
19
  # --- Exadata Specs ---
20
  exadata_specs = {
21
  "X7": {"Quarter Rack": {"max_iops": 350000, "max_throughput": 25}, "Half Rack": {"max_iops": 700000, "max_throughput": 50}, "Full Rack": {"max_iops": 1400000, "max_throughput": 100}},
 
131
  """
132
 
133
  response = client.chat.completions.create(
134
+ model=llm_model,
135
  messages=[
136
  {"role": "system", "content": "You are the strict Oracle AWR Health Analysis Agent."},
137
  {"role": "user", "content": prompt}
 
140
 
141
  return response.choices[0].message.content.strip()
142
 
 
143
  class RaterAgent:
144
+ def rate(self, content):
145
  prompt = f"Rate the following analysis from 1-5 stars and explain:\n\n{content}"
146
+
147
+ response = openrouter.chat.completions.create(
148
+ model="mistralai/Mixtral-8x7B-Instruct", # FORCE to use Mixtral via OpenRouter
149
  messages=[{"role": "user", "content": prompt}]
150
  )
151
+
152
  return response.choices[0].message.content.strip()
153
 
154
+
155
  # === Main Process ===
156
  def process_awr(awr_text, threshold, performance_test_mode, exadata_model, rack_size, llm_model):
157
  analyzer = CriticalAnalyzerAgent()
 
163
 
164
  analysis = analyzer.analyze(awr_text, performance_test_mode, exadata_model, rack_size, llm_model)
165
  health_status = health.check_health(awr_text, llm_model)
166
+ rating_text = rater.rate(analysis)
167
 
168
  stars = 0
169
  match = re.search(r"(\d+)", rating_text)