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

Function get_probs_list

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

解析 response 中的 token 文本列表

(response)

Source from the content-addressed store, hash-verified

120
121
122def get_probs_list(response):
123 """解析 response 中的 token 文本列表"""
124 probs_list = []
125
126 try:
127 content_logprobs = response["choices"][0]["logprobs"]["content"]
128 except (KeyError, IndexError, TypeError) as e:
129 base_logger.error(f"解析失败:{e}")
130 return []
131
132 for token_info in content_logprobs:
133 token = token_info.get("logprob")
134 if token is not None:
135 probs_list.append(math.exp(token))
136
137 base_logger.info(f"probs List:{probs_list}")
138 return probs_list

Callers 1

Calls 3

errorMethod · 0.45
getMethod · 0.45
infoMethod · 0.45

Tested by 1