extensions/openai: Fixes for: embeddings, tokens, better errors. +Docs update, +Images, +logit_bias/logprobs, +more. (#3122)

This commit is contained in:
matatonic 2023-07-24 10:28:12 -04:00 committed by GitHub
parent 1141987a0d
commit 90a4ab631c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 215 additions and 143 deletions

View file

@ -1,6 +1,6 @@
from extensions.openai.utils import float_list_to_base64
from modules.text_generation import encode, decode
import numpy as np
def token_count(prompt):
tokens = encode(prompt)[0]
@ -12,14 +12,13 @@ def token_count(prompt):
}
def token_encode(input, encoding_format=''):
def token_encode(input, encoding_format):
# if isinstance(input, list):
tokens = encode(input)[0]
return {
'results': [{
'encoding_format': encoding_format,
'tokens': float_list_to_base64(tokens) if encoding_format == "base64" else tokens,
'tokens': tokens,
'length': len(tokens),
}]
}