INNER CODE UNIT · Python
_ollama_num_ctx
bigsk1/voice-chat-ai · app/app.py:206
def _ollama_num_ctx():
if not OLLAMA_NUM_CTX:
return None
try:
value = int(OLLAMA_NUM_CTX)
if value <= 0:
raise ValueError
return value
except ValueError:
print(f"{YELLOW}Invalid OLLAMA_NUM_CTX: {OLLAMA_NUM_CTX!r} — must be a positive integer; ignoring.{RESET_COLOR}")
return None
def ollama_request_options(**extra):
options = dict(extra)
num_ctx = _ollama_num_ctx()
if num_ctx is not None:
options["num_ctx"] = num_ctx
return options