Commit ·
d84375f
1
Parent(s): a1e0c1e
fix
Browse files- __pycache__/app.cpython-313.pyc +0 -0
- app.py +2 -69
__pycache__/app.cpython-313.pyc
CHANGED
|
Binary files a/__pycache__/app.cpython-313.pyc and b/__pycache__/app.cpython-313.pyc differ
|
|
|
app.py
CHANGED
|
@@ -1,81 +1,14 @@
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
-
import json
|
| 4 |
import os
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
from server.app import app as api_app
|
| 9 |
-
from support_ops_env.models import Action
|
| 10 |
-
from support_ops_env.tasks import list_task_ids
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
def reset_env(task_id: str) -> str:
|
| 14 |
-
from server.app import _http_env
|
| 15 |
-
|
| 16 |
-
observation = _http_env.reset(task_id=task_id)
|
| 17 |
-
return json.dumps(observation.model_dump(), indent=2)
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
def step_env(task_id: str, action_type: str, target: str, value: str) -> tuple[str, str]:
|
| 21 |
-
from server.app import _http_env
|
| 22 |
-
|
| 23 |
-
state = _http_env.state()
|
| 24 |
-
if state.task_id != task_id or (state.step_count == 0 and not state.done):
|
| 25 |
-
_http_env.reset(task_id=task_id)
|
| 26 |
-
|
| 27 |
-
action = Action(action_type=action_type, target=target or "T1", value=value or None)
|
| 28 |
-
observation, reward, done, info = _http_env.step(action)
|
| 29 |
-
payload = {
|
| 30 |
-
"reward": reward.model_dump(),
|
| 31 |
-
"done": done,
|
| 32 |
-
"info": info,
|
| 33 |
-
}
|
| 34 |
-
return json.dumps(observation.model_dump(), indent=2), json.dumps(payload, indent=2)
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
with gr.Blocks(title="SupportOpsEnv") as demo:
|
| 38 |
-
gr.Markdown("# SupportOpsEnv")
|
| 39 |
-
gr.Markdown("Multi-step support triage benchmark with deterministic graders.")
|
| 40 |
-
|
| 41 |
-
task_id = gr.Dropdown(choices=list_task_ids(), value=list_task_ids()[0], label="Task")
|
| 42 |
-
action_type = gr.Dropdown(
|
| 43 |
-
choices=[
|
| 44 |
-
"inspect_ticket",
|
| 45 |
-
"request_context",
|
| 46 |
-
"set_priority",
|
| 47 |
-
"set_route",
|
| 48 |
-
"set_resolution",
|
| 49 |
-
"escalate",
|
| 50 |
-
"rank_queue",
|
| 51 |
-
"finalize",
|
| 52 |
-
],
|
| 53 |
-
value="inspect_ticket",
|
| 54 |
-
label="Action Type",
|
| 55 |
-
)
|
| 56 |
-
target = gr.Textbox(value="T1", label="Target Ticket")
|
| 57 |
-
value = gr.Textbox(label="Value")
|
| 58 |
-
observation_output = gr.Code(label="Observation", language="json")
|
| 59 |
-
result_output = gr.Code(label="Step Result", language="json")
|
| 60 |
-
|
| 61 |
-
reset_button = gr.Button("Reset")
|
| 62 |
-
step_button = gr.Button("Step")
|
| 63 |
-
|
| 64 |
-
reset_button.click(reset_env, inputs=[task_id], outputs=[observation_output])
|
| 65 |
-
step_button.click(
|
| 66 |
-
step_env,
|
| 67 |
-
inputs=[task_id, action_type, target, value],
|
| 68 |
-
outputs=[observation_output, result_output],
|
| 69 |
-
)
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
app = gr.mount_gradio_app(api_app, demo, path="/ui")
|
| 73 |
|
| 74 |
|
| 75 |
def main(host: str = "0.0.0.0", port: int | None = None) -> None:
|
| 76 |
import uvicorn
|
| 77 |
|
| 78 |
-
resolved_port = port or int(os.getenv("PORT",
|
| 79 |
uvicorn.run(app, host=host, port=resolved_port)
|
| 80 |
|
| 81 |
|
|
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
|
|
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
from server.app import app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
def main(host: str = "0.0.0.0", port: int | None = None) -> None:
|
| 9 |
import uvicorn
|
| 10 |
|
| 11 |
+
resolved_port = port or int(os.getenv("PORT", "7860"))
|
| 12 |
uvicorn.run(app, host=host, port=resolved_port)
|
| 13 |
|
| 14 |
|