Error
InvalidRequestError at /chatgpt/
'0' is not of type 'integer' - 'max_tokens'
Request Method: POST
Request URL: http://localhost:8000/chatgpt/
Django Version: 4.1.9
Exception Type: InvalidRequestError
Exception Value:
'0' is not of type 'integer' - 'max_tokens'
my code is
dynamic_max_tokens = request.POST.get('max_tokens')
dynamic_top_p = request.POST.get('top_p')
dynamic_temperature = request.POST.get('temperature')
dynamic_modal = request.POST.get('modal')
dynamic_frequency_penalty = request.POST.get('frequency_penalty')
dynamic_presence_penalty = request.POST.get('presence_penalty')
# max_tokens = int(dynamic_max_tokens) if dynamic_max_tokens and dynamic_max_tokens != '0' else 100
max_tokens = dynamic_max_tokens if dynamic_max_tokens is not None else 0.5
Solution
max_tokens = int(dynamic_max_tokens) if dynamic_max_tokens is not None else 0.5
==================or===================
max_tokens = int(dynamic_max_tokens) if dynamic_max_tokens and dynamic_max_tokens != '0' else 100
Top comments (0)