Add fallback token limit in llm.utils.create_chat_completion (#4839)

Co-authored-by: Reinier van der Leer <github@pwuts.nl>
This commit is contained in:
Luke
2023-06-29 09:26:49 -04:00
committed by GitHub
parent 30f153e695
commit 975094fcdd

View File

@@ -115,6 +115,8 @@ def create_chat_completion(
model = prompt.model.name
if temperature is None:
temperature = config.temperature
if max_tokens is None:
max_tokens = OPEN_AI_CHAT_MODELS[model].max_tokens - prompt.token_length
logger.debug(
f"{Fore.GREEN}Creating chat completion with model {model}, temperature {temperature}, max_tokens {max_tokens}{Fore.RESET}"