feat: add token column to mcp_servers and pipe through to sse server config (#2775)
Co-authored-by: Jin Peng <jinjpeng@Jins-MacBook-Pro.local>
This commit is contained in:
@@ -100,7 +100,11 @@ def num_tokens_from_functions(functions: List[dict], model: str = "gpt-4"):
|
||||
try:
|
||||
if field == "type":
|
||||
function_tokens += 2
|
||||
function_tokens += len(encoding.encode(v["type"]))
|
||||
# Handle both string and array types, e.g. {"type": ["string", "null"]}
|
||||
if isinstance(v["type"], list):
|
||||
function_tokens += len(encoding.encode(",".join(v["type"])))
|
||||
else:
|
||||
function_tokens += len(encoding.encode(v["type"]))
|
||||
elif field == "description":
|
||||
function_tokens += 2
|
||||
function_tokens += len(encoding.encode(v["description"]))
|
||||
|
||||
Reference in New Issue
Block a user