(prompt)
| 53 | # chatgpt api |
| 54 | # 将此函数替换为付费api |
| 55 | def plain_chat(prompt): |
| 56 | headers={ |
| 57 | 'Content-type':'application/json', |
| 58 | 'Accept':'application/json' |
| 59 | } |
| 60 | url= 'your_paid_chatgpt_api' |
| 61 | # 构造 post 数据 |
| 62 | postdata = {"content": prompt} |
| 63 | postdata = json.dumps(postdata) |
| 64 | r = requests.post(url, data=postdata, headers=headers) |
| 65 | #print(r) |
| 66 | json_content = json.loads(r.text) |
| 67 | answer = json_content["texts"] |
| 68 | return answer |
| 69 | |
| 70 | def read_file_lines(file): |
| 71 | with open(file, 'r', errors='ignore', encoding='utf8') as f: |