Cleans up the generated code text.
(text: str)
| 47 | |
| 48 | |
| 49 | def 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 | |
| 63 | def topk_fun(logits, topk=5): |
no outgoing calls
no test coverage detected