MCPcopy Create free account
hub / github.com/AsyncFuncAI/deepwiki-open / get_probabilities

Function get_probabilities

api/azureai_client.py:103–115  ·  view source on GitHub ↗

r"""Get the probabilities of each token in the completion.

(completion: ChatCompletion)

Source from the content-addressed store, hash-verified

101
102
103def get_probabilities(completion: ChatCompletion) -> List[List[TokenLogProb]]:
104 r"""Get the probabilities of each token in the completion."""
105 log_probs = []
106 for c in completion.choices:
107 content = c.logprobs.content
108 print(content)
109 log_probs_for_choice = []
110 for openai_token_logprob in content:
111 token = openai_token_logprob.token
112 logprob = openai_token_logprob.logprob
113 log_probs_for_choice.append(TokenLogProb(token=token, logprob=logprob))
114 log_probs.append(log_probs_for_choice)
115 return log_probs
116
117
118class AzureAIClient(ModelClient):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected