MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / get_token_list

Function get_token_list

tests/ce/server/core/utils.py:84–100  ·  view source on GitHub ↗

解析 response 中的 token 文本列表

(response)

Source from the content-addressed store, hash-verified

82
83
84def get_token_list(response):
85 """解析 response 中的 token 文本列表"""
86 token_list = []
87
88 try:
89 content_logprobs = response["choices"][0]["logprobs"]["content"]
90 except (KeyError, IndexError, TypeError) as e:
91 base_logger.error(f"解析失败:{e}")
92 return []
93
94 for token_info in content_logprobs:
95 token = token_info.get("token")
96 if token is not None:
97 token_list.append(token)
98
99 base_logger.info(f"Token List:{token_list}")
100 return token_list
101
102
103def get_logprobs_list(response):

Callers 3

test_stop_sequenceFunction · 0.90
test_bad_words_filteringFunction · 0.90

Calls 3

errorMethod · 0.45
getMethod · 0.45
infoMethod · 0.45

Tested by 3

test_stop_sequenceFunction · 0.72
test_bad_words_filteringFunction · 0.72