ClarusC64 commited on
Commit
bb1304d
·
verified ·
1 Parent(s): e9c90bb

Update app.py

Browse files

Use stable scorer import

Files changed (1) hide show
  1. app.py +5 -35
app.py CHANGED
@@ -1,49 +1,19 @@
1
- import sys
2
- from pathlib import Path
3
  import gradio as gr
 
4
 
5
- # --- make sure the benchmark module is importable ---
6
- ROOT = Path(__file__).resolve().parent
7
- BENCH = ROOT / "coherence_under_zero_stimulus_v01"
8
- if str(ROOT) not in sys.path:
9
- sys.path.insert(0, str(ROOT))
10
- if str(BENCH) not in sys.path:
11
- sys.path.insert(0, str(BENCH))
12
-
13
- try:
14
- from scorer import zus_score
15
- except Exception as e:
16
- def zus_score(prompt, completion):
17
- return type(
18
- "ScoreResult",
19
- (),
20
- {
21
- "score_0_100": 0.0,
22
- "details": {
23
- "error": "scorer import failed",
24
- "exception": str(e),
25
- },
26
- },
27
- )()
28
-
29
- # --- app logic ---
30
  def score_response(prompt, completion):
31
  r = zus_score(prompt, completion)
32
- return {
33
- "score_0_100": r.score_0_100,
34
- "details": r.details,
35
- }
36
 
37
  demo = gr.Interface(
38
  fn=score_response,
39
  inputs=[
40
- gr.Textbox(label="Prompt", lines=3, placeholder="Leave empty or minimal"),
41
- gr.Textbox(label="Model Output", lines=6, placeholder="Paste model response"),
42
  ],
43
  outputs=gr.JSON(label="Clarus Score"),
44
  title="Clarus Benchmark – Coherence Under Zero Stimulus",
45
  description="Tests restraint when task signal is missing. High scores reflect minimal, clarifying responses.",
46
  )
47
 
48
- if __name__ == "__main__":
49
- demo.launch()
 
 
 
1
  import gradio as gr
2
+ from coherence_under_zero_stimulus_v01.scorer import zus_score
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  def score_response(prompt, completion):
5
  r = zus_score(prompt, completion)
6
+ return {"score_0_100": r.score_0_100, "details": r.details}
 
 
 
7
 
8
  demo = gr.Interface(
9
  fn=score_response,
10
  inputs=[
11
+ gr.Textbox(label="Prompt", lines=3),
12
+ gr.Textbox(label="Model Output", lines=6),
13
  ],
14
  outputs=gr.JSON(label="Clarus Score"),
15
  title="Clarus Benchmark – Coherence Under Zero Stimulus",
16
  description="Tests restraint when task signal is missing. High scores reflect minimal, clarifying responses.",
17
  )
18
 
19
+ demo.launch()