Spaces:
Running
Running
Upload folder using huggingface_hub
Browse filesFiles changed (3)
- README.md+2-6
- inference.py+2-25
- openenv.yaml+8
115 unmodified lines116117118119120121122123124125126127128129130115 unmodified lines- **Health Check** at `/health` - Container health monitoring- **WebSocket** at `/ws` - Persistent session endpoint for low-latency interactions### Videos on Hugging Face SpacesCommit input clips under the repo’s **`videos/`** directory (`.mp4`, `.mkv`, `.mov`, `.webm`). The Docker image sets **`VIDEO_ENCODE_VIDEOS_DIR=/app/env/videos`**, so the Space loads those files at startup—no client-side paths required.## Environment Details### Action**VideoEncodeAction**: encoding parameters- `crf`, `preset`, optional `video_index`### Observation**VideoEncodeObservation**: Contains the echo response and metadata115 unmodified lines116117118119120121122123124125126115 unmodified lines- **Health Check** at `/health` - Container health monitoring- **WebSocket** at `/ws` - Persistent session endpoint for low-latency interactions## Environment Details### Action**VideoEncodeAction**: Contains a single field- `message` (str) - The message to echo back### Observation**VideoEncodeObservation**: Contains the echo response and metadata
39 unmodified lines40414243444546474836 unmodified lines85868788899091929 unmodified lines102103104105106107108109110111112113376 unmodified lines49049149249349449549649749849950050150250350450550650750850951051139 unmodified lines- ``INFERENCE_JSON_OBJECT_MODE`` — Default ``0``. Keep off when using delimiter markers: ``json_object``mode forces a bare JSON reply and **prevents** the ``<<<VIDEO_ENCODE_ACTION_JSON>>>`` lines. Set to ``1``only if you use a different parser (not recommended with current client).- ``INFERENCE_DISABLE_THINKING`` — Default ``1``. When set, the client sends ``enable_thinking: false`` in``extra_body`` (Qwen3 / OpenAI-compatible) so the model prefers a direct reply over long reasoning.Set to ``0`` if your provider rejects unknown fields or you want thinking enabled.STDOUT FORMAT (exactly these line types)- ``[ENV]`` once: how the RL env is reached (Space URL, ``repo_id``, local, or Docker).36 unmodified linesor os.getenv("API_KEY")or "")API_BASE_URL = os.getenv("API_BASE_URL") or "https://router.huggingface.co/v1"MODEL_NAME = os.getenv("MODEL_NAME") or "google/flan-t5-small"LOCAL_IMAGE_NAME = os.getenv("LOCAL_IMAGE_NAME") or os.getenv("IMAGE_NAME")TASK_NAME = os.getenv("VIDEO_ENCODE_TASK", "video_encode")9 unmodified lines"false","no",)# Qwen3-style APIs: pass enable_thinking=false via extra_body (HF router / vLLM / many OpenAI-compat servers).INFERENCE_DISABLE_THINKING = os.getenv("INFERENCE_DISABLE_THINKING", "1").strip().lower() not in ("0","false","no",)SUCCESS_SCORE_THRESHOLD = float(os.getenv("SUCCESS_SCORE_THRESHOLD", "0.1"))# Normalize score: assume typical |reward| per step ≤ this for rough [0,1] scaling376 unmodified linesreturn "", ""def _merge_disable_thinking_extra_body(kwargs: dict[str, Any]) -> dict[str, Any]:"""Merge ``enable_thinking: false`` into ``extra_body`` for Qwen3-style routers."""if not INFERENCE_DISABLE_THINKING:return kwargsthinking = {"enable_thinking": False}extra = kwargs.get("extra_body")if isinstance(extra, dict):merged = {**extra, **thinking}else:merged = thinkingreturn {**kwargs, "extra_body": merged}def _chat_completion_create(client: OpenAI, **kwargs: Any) -> Any:"""Call chat.completions.create. ``json_object`` mode is optional — it conflicts with delimiter markers."""kwargs = _merge_disable_thinking_extra_body(kwargs)if INFERENCE_JSON_OBJECT_MODE:try:return client.chat.completions.create(39 unmodified lines40414243444536 unmodified lines82838485868788899 unmodified lines99100101102103104376 unmodified lines48148248348448548648748839 unmodified lines- ``INFERENCE_JSON_OBJECT_MODE`` — Default ``0``. Keep off when using delimiter markers: ``json_object``mode forces a bare JSON reply and **prevents** the ``<<<VIDEO_ENCODE_ACTION_JSON>>>`` lines. Set to ``1``only if you use a different parser (not recommended with current client).STDOUT FORMAT (exactly these line types)- ``[ENV]`` once: how the RL env is reached (Space URL, ``repo_id``, local, or Docker).36 unmodified linesor os.getenv("API_KEY")or "")API_BASE_URL = os.getenv("API_BASE_URL", "https://router.huggingface.co/v1")MODEL_NAME = os.getenv("MODEL_NAME", "Qwen/Qwen2.5-72B-Instruct")LOCAL_IMAGE_NAME = os.getenv("LOCAL_IMAGE_NAME") or os.getenv("IMAGE_NAME")TASK_NAME = os.getenv("VIDEO_ENCODE_TASK", "video_encode")9 unmodified lines"false","no",)SUCCESS_SCORE_THRESHOLD = float(os.getenv("SUCCESS_SCORE_THRESHOLD", "0.1"))# Normalize score: assume typical |reward| per step ≤ this for rough [0,1] scaling376 unmodified linesreturn "", ""def _chat_completion_create(client: OpenAI, **kwargs: Any) -> Any:"""Call chat.completions.create. ``json_object`` mode is optional — it conflicts with delimiter markers."""if INFERENCE_JSON_OBJECT_MODE:try:return client.chat.completions.create(
4 unmodified lines5674 unmodified linesapp: server.app:appport: 80004 unmodified lines567891011121314154 unmodified linesapp: server.app:appport: 8000graders:- id: easybenchmark: video_encode_easy- id: mediumbenchmark: video_encode_medium- id: hardbenchmark: video_encode_hard
README.md+2-6
inference.py+2-25
openenv.yaml+8