MCPcopy Create free account
hub / github.com/zai-org/CodeGeeX / truncate_text

Function truncate_text

codegeex/mindspore/src/generate_humaneval.py:49–60  ·  view source on GitHub ↗

Cleans up the generated code text.

(text: str)

Source from the content-addressed store, hash-verified

47
48
49def truncate_text(text: str):
50 """
51 Cleans up the generated code text.
52 """
53 # end_words = ['\ndef', '\nclass', '\nif', '\n#', '\nprint', '<|endoftext|>']
54 end_words = ['\n}']
55 for w in end_words:
56 idx = text.find(w)
57 if idx != -1:
58 text = text[:idx] + w
59 # text = text[:idx]
60 return text
61
62
63def topk_fun(logits, topk=5):

Callers 1

generate_incrementFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected