Closed 00drdelius closed 8 months ago
Done.
headers = {
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0',
'Accept': 'text/event-stream, text/event-stream',
'Accept-Language': 'en-US,en;q=0.5',
'Referer': 'https://claude.ai/chats',
'Content-Type': 'application/json',
'Origin': 'https://claude.ai',
'DNT': '1',
'Connection': 'keep-alive',
'Cookie': f'{self.cookie}',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'TE': 'trailers'
}
# change format added
headers = [f"{k}: {v}".encode() for k,v in headers.items()]
简单想尝试下但报错: Exception has occurred: TypeError (note: full exception trace is shown but execution is paused at: _run_module_as_main) initializer for ctype 'char ' must be a bytes or list or tuple, not str File "C:\Users\admin\AppData\Roaming\Python\Python310\site-packages\curl_cffi\curl.py", line 174, in setopt self._headers = lib.curl_slist_append(self._headers, header) File "D:\models\datasets\claude2(fetch)\Claude2_PyAPI\claude_api.py", line 179, in send_message c.setopt(CurlOpt.HTTPHEADER, str(headers)) File "D:\models\datasets\claude2(fetch)\claude2.py", line 26, in
response = claude_api.send_message(prompt, conversation_id)
File "C:\Program Files\Python310\Lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Program Files\Python310\Lib\runpy.py", line 196, in _run_module_as_main (Current frame)
return _run_code(code, main_globals, None,
TypeError: initializer for ctype 'char ' must be a bytes or list or tuple, not str