Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files39 unmodified lines40414243444553 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).53 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(39 unmodified lines40414243444546474853 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).53 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(
inference.py+23