Spaces:
Running
Running
Download tests/application/test_model_fallback_decision.py from dherain24/claude-proxy: direct link, hf CLI and curl.
- Browser
- Download file 4.28 kB
-
https://huggingface.co/spaces/dherain24/claude-proxy/resolve/main/tests/application/test_model_fallback_decision.py
- Command line
-
hf download hf://spaces/dherain24/claude-proxy/tests/application/test_model_fallback_decision.py
-
curl -L -o test_model_fallback_decision.py https://huggingface.co/spaces/dherain24/claude-proxy/resolve/main/tests/application/test_model_fallback_decision.py
4.28 kB
| """The pure step that follows one failed model candidate.""" | |
| import pytest | |
| from free_claude_code.application.model_fallback.decision import ( | |
| CandidateFailure, | |
| Fail, | |
| Fallback, | |
| Handoff, | |
| next_step, | |
| ) | |
| from free_claude_code.core.stream_recovery import ( | |
| ContinuationSeed, | |
| DeliveredPrefix, | |
| RecoveryAction, | |
| SourceRecoverySnapshot, | |
| StreamFailureContext, | |
| ) | |
| RESTART = RecoveryAction.RESTART | |
| CONTINUE = RecoveryAction.CONTINUE | |
| SEED = ContinuationSeed("messages", ({"type": "text", "text": "a"},)) | |
| def _prefix(*, has_calls: bool = False) -> DeliveredPrefix: | |
| return DeliveredPrefix( | |
| text="a", | |
| thinking="", | |
| has_calls=has_calls, | |
| eligible=True, | |
| can_handoff=True, | |
| unsafe_reason=None, | |
| continuation=SEED, | |
| ) | |
| def _failure( | |
| source: SourceRecoverySnapshot | None, *, produced_output: bool = False | |
| ) -> CandidateFailure: | |
| return CandidateFailure( | |
| context=StreamFailureContext(source) if source is not None else None, | |
| retryable=True, | |
| produced_output=produced_output, | |
| ) | |
| CLEAN = SourceRecoverySnapshot() | |
| def test_next_step(failure, released, prefix, seed, has_next, expected): | |
| assert ( | |
| next_step( | |
| failure, | |
| content_released=released, | |
| prefix=prefix, | |
| seed=seed, | |
| has_next=has_next, | |
| ) | |
| == expected | |
| ) | |
| def test_prefix_is_ignored_without_stream_evidence(): | |
| step = next_step( | |
| _failure(None), | |
| content_released=True, | |
| prefix=_prefix(has_calls=True), | |
| seed=SEED, | |
| has_next=True, | |
| ) | |
| assert step == Fallback(SEED, CONTINUE, "no_candidate_output") | |