mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
add conversation API (#35)
This commit is contained in:
@ -58,9 +58,11 @@ def findMaxTm(fnm):
|
||||
print("WARNING: can't find " + fnm)
|
||||
return m
|
||||
|
||||
|
||||
|
||||
encoder = tiktoken.encoding_for_model("gpt-3.5-turbo")
|
||||
|
||||
def num_tokens_from_string(string: str) -> int:
|
||||
"""Returns the number of tokens in a text string."""
|
||||
encoding = tiktoken.get_encoding('cl100k_base')
|
||||
num_tokens = len(encoding.encode(string))
|
||||
return num_tokens
|
||||
num_tokens = len(encoder.encode(string))
|
||||
return num_tokens
|
||||
|
||||
|
||||
Reference in New Issue
Block a user