extensions/openai: Fixes for: embeddings, tokens, better errors. +Docs update, +Images, +logit_bias/logprobs, +more. (#3122)
This commit is contained in:
parent
1141987a0d
commit
90a4ab631c
10 changed files with 215 additions and 143 deletions
|
@ -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),
|
||||
}]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue