Add support for GPT-5.1 and GPT-5.2: update token limits and pricing
This commit is contained in:
@@ -191,8 +191,10 @@ class IntegrationSettingsViewSet(viewsets.ViewSet):
|
||||
# Get model from config or use default (reference plugin: get_option('igny8_model', 'gpt-4.1'))
|
||||
model = (config or {}).get('model', 'gpt-4.1') if config else 'gpt-4.1'
|
||||
|
||||
# Get max_tokens from config or use default
|
||||
max_tokens = (config or {}).get('max_tokens', 8192) if config else 8192
|
||||
# Get max_tokens from config or use default based on model
|
||||
# GPT-5.1 and GPT-5.2 use 16384 max_tokens by default
|
||||
default_max_tokens = 16384 if model in ['gpt-5.1', 'gpt-5.2'] else 8192
|
||||
max_tokens = (config or {}).get('max_tokens', default_max_tokens) if config else default_max_tokens
|
||||
|
||||
# Check if test with response is requested (reference plugin: $with_response parameter)
|
||||
with_response = (config or {}).get('with_response', False) if config else False
|
||||
@@ -207,10 +209,15 @@ class IntegrationSettingsViewSet(viewsets.ViewSet):
|
||||
'content': 'Reply with exactly: OK! Ping Received'
|
||||
}
|
||||
],
|
||||
'max_tokens': max_tokens,
|
||||
'temperature': 0.7,
|
||||
}
|
||||
|
||||
# GPT-5.1 and GPT-5.2 use max_completion_tokens instead of max_tokens
|
||||
if model in ['gpt-5.1', 'gpt-5.2']:
|
||||
request_body['max_completion_tokens'] = max_tokens
|
||||
else:
|
||||
request_body['max_tokens'] = max_tokens
|
||||
|
||||
try:
|
||||
response = requests.post(
|
||||
'https://api.openai.com/v1/chat/completions',
|
||||
|
||||
Reference in New Issue
Block a user