(do_sample, max_length, top_k, top_p, temperature, repetition_penalty)
| 46 | |
| 47 | |
| 48 | def check_ex(do_sample, max_length, top_k, top_p, temperature, repetition_penalty): |
| 49 | flag = True |
| 50 | try: |
| 51 | if do_sample != None and (do_sample not in [True, False] or not isinstance(do_sample, bool)): |
| 52 | flag = False |
| 53 | if max_length != None and (not 0 < max_length <= 4096 or not isinstance(max_length, int)): |
| 54 | flag = False |
| 55 | if top_k != None and (not 0 < top_k < 100 or not isinstance(top_k, int)): |
| 56 | flag = False |
| 57 | if top_p != None and (not 0.0 < top_p < 1.0 or not isinstance(top_p, float)): |
| 58 | flag = False |
| 59 | if temperature != None and (not 0.0 < temperature < 1.0 or not isinstance(temperature, float)): |
| 60 | flag = False |
| 61 | if repetition_penalty != None and ( |
| 62 | not 1.0 < repetition_penalty < 100.0 or not isinstance(repetition_penalty, float)): |
| 63 | flag = False |
| 64 | return flag |
| 65 | except Exception: |
| 66 | flag = False |
| 67 | return flag |
| 68 | |
| 69 | |
| 70 | def streamresponse_v2(tokenizer, query, history, do_sample, max_length, top_k, top_p, temperature, repetition_penalty): |
no outgoing calls
no test coverage detected