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

Function get_logprobs_list

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

解析 response 中的 token 文本列表

(response)

Source from the content-addressed store, hash-verified

101
102
103def get_logprobs_list(response):
104 """解析 response 中的 token 文本列表"""
105 logprobs_list = []
106
107 try:
108 content_logprobs = response["choices"][0]["logprobs"]["content"]
109 except (KeyError, IndexError, TypeError) as e:
110 base_logger.error(f"解析失败:{e}")
111 return []
112
113 for token_info in content_logprobs:
114 token = token_info.get("logprob")
115 if token is not None:
116 logprobs_list.append(token)
117
118 base_logger.info(f"Logprobs List:{logprobs_list}")
119 return logprobs_list
120
121
122def get_probs_list(response):

Callers

nothing calls this directly

Calls 3

errorMethod · 0.45
getMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected