File size: 1,257 Bytes
2e34d5b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def get_args_or_none(data):
    system_prompt = data.pop("system-prompt", "You are Gemma. Assist user with whatever they require, in a safe and moral manner.")
    inputs = data.pop("inputs", "")
    temperature = data.pop("temperature", None)
    if not temperature or temperature is None:
        temperature = data.pop("temp", 0.33)
    if temperature > 3 or temperature < 0:
        return {
            0: False,
            "status": "error",
            "reason": "temperature",
            "reason": "invalid temperature ( 0.01 - 1.00 only allowed )"
        }
    top_p = data.pop("top-p", 0.85)
    if top_p > 3 or top_p < 0:
        return {
            0: False,
            "status": "error",
            "reason": "top_p",
            "description": "invalid top percentage ( 0.01 - 1.00 only allowed )"
        }
    top_k = data.pop("top-k", 42)
    if top_k > 100 or top_k < 0:
        return {
            0: False,
            "status": "error",
            "reason": "top_k",
            "description": "invalid top k ( 1 - 99 only allowed )"
        }
    return {
        0: True,
        "inputs": inputs,
        "system_prompt": system_prompt,
        "temperature": temperature,
        "top_p": top_p,
        "top_k": top_k
    }