Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,10 @@ import os
|
|
| 8 |
import glob
|
| 9 |
import matplotlib.pyplot as plt
|
| 10 |
import numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
YOUR_OPENROUTER_API_KEY = os.getenv('OPENROUTER_API_KEY')
|
| 13 |
client = OpenAI(
|
|
@@ -235,7 +239,9 @@ def run_detector(image, model):
|
|
| 235 |
}
|
| 236 |
],
|
| 237 |
)
|
| 238 |
-
|
|
|
|
|
|
|
| 239 |
return resp.choices[0].message.content.strip()
|
| 240 |
|
| 241 |
def test_injection(prompt, model):
|
|
@@ -245,7 +251,9 @@ def test_injection(prompt, model):
|
|
| 245 |
messages=[{"role": "user", "content": prompt}],
|
| 246 |
)
|
| 247 |
reply = response.choices[0].message.content
|
| 248 |
-
|
|
|
|
|
|
|
| 249 |
except Exception as e:
|
| 250 |
reply = f"Error with {model}: {e}"
|
| 251 |
return f"=== {model} ===\n{reply}"
|
|
@@ -549,7 +557,9 @@ with gr.Blocks(theme=theme, css=light_blue_glass_css, title="Phoenikz Unified Ap
|
|
| 549 |
raw_analysis, visual_analysis = "", "No response to analyze."
|
| 550 |
if response_output and not response_output.startswith("Error:"):
|
| 551 |
raw_analysis, visual_analysis = assess_text_harmfulness(response_output, models)
|
| 552 |
-
|
|
|
|
|
|
|
| 553 |
|
| 554 |
return (
|
| 555 |
gr.update(value=new_history),
|
|
|
|
| 8 |
import glob
|
| 9 |
import matplotlib.pyplot as plt
|
| 10 |
import numpy as np
|
| 11 |
+
from datetime import datetime
|
| 12 |
+
import pytz
|
| 13 |
+
|
| 14 |
+
|
| 15 |
|
| 16 |
YOUR_OPENROUTER_API_KEY = os.getenv('OPENROUTER_API_KEY')
|
| 17 |
client = OpenAI(
|
|
|
|
| 239 |
}
|
| 240 |
],
|
| 241 |
)
|
| 242 |
+
IST = pytz.timezone('Asia/Kolkata')
|
| 243 |
+
timestamp = datetime.now(IST).strftime('%Y-%m-%d %I:%M:%S %p IST')
|
| 244 |
+
print(f"[{datetime.now(IST).strftime('%Y-%m-%d %I:%M:%S %p IST')}] Image Scanner | Model: {model} | This is image: {os.path.basename(image)} | This is response: '{resp.choices[0].message.content.strip()[:300]}...' (len: {len(resp.choices[0].message.content.strip())})")
|
| 245 |
return resp.choices[0].message.content.strip()
|
| 246 |
|
| 247 |
def test_injection(prompt, model):
|
|
|
|
| 251 |
messages=[{"role": "user", "content": prompt}],
|
| 252 |
)
|
| 253 |
reply = response.choices[0].message.content
|
| 254 |
+
IST = pytz.timezone('Asia/Kolkata')
|
| 255 |
+
|
| 256 |
+
print(f"[{datetime.now(IST).strftime('%Y-%m-%d %I:%M:%S %p IST')}] Text Prompt Tester | Model: {model} | This is prompt: '{prompt[:300]}...' | This is response: '{reply[:300]}...' (len_prompt: {len(prompt)}, len_reply: {len(reply)})")
|
| 257 |
except Exception as e:
|
| 258 |
reply = f"Error with {model}: {e}"
|
| 259 |
return f"=== {model} ===\n{reply}"
|
|
|
|
| 557 |
raw_analysis, visual_analysis = "", "No response to analyze."
|
| 558 |
if response_output and not response_output.startswith("Error:"):
|
| 559 |
raw_analysis, visual_analysis = assess_text_harmfulness(response_output, models)
|
| 560 |
+
IST = pytz.timezone('Asia/Kolkata')
|
| 561 |
+
|
| 562 |
+
print(f"[{datetime.now(IST).strftime('%Y-%m-%d %I:%M:%S %p IST')}] Chat & Analysis | Model: {model} | This is user input: '{user_txt[:300]}...' | This is response: '{(response_output or 'No response')[:300]}...' (len_user: {len(user_txt)}, len_resp: {len(response_output or 'No response')})")
|
| 563 |
|
| 564 |
return (
|
| 565 |
gr.update(value=new_history),
|