Added missing notes; Minor formatting fixes

This commit is contained in:
JGalego 2024-05-16 12:22:20 +01:00
parent 815bd7430e
commit 9889080f32
2 changed files with 9 additions and 5 deletions

View File

@ -69,6 +69,7 @@ class OpenAIModel(ModelBackend):
num_prompt_tokens = len(encoding.encode(string))
gap_between_send_receive = 15 * len(kwargs["messages"])
num_prompt_tokens += gap_between_send_receive
if openai_new_api:
# Experimental, add base_url
if BASE_URL:

View File

@ -92,8 +92,11 @@ def escape_string(value):
return value
def is_url(url):
try:
result = urlparse(url)
return all([result.scheme, result.netloc])
except ValueError:
return False
"""
Adapted from https://stackoverflow.com/questions/7160737/how-to-validate-a-url-in-python-malformed-or-not
"""
try:
result = urlparse(url)
return all([result.scheme, result.netloc])
except ValueError:
return False