jtsang4 / claude-to-chatgpt

This project converts the API of Anthropic's Claude model to the OpenAI Chat API format.
MIT License
1.26k stars 150 forks source link

Cloudflare部署时输出不全,大概判断是claude响应穿过来的Json数据块处理不对 #22

Open Jialinvip opened 1 year ago

Jialinvip commented 1 year ago

以下是日志: { "outcome": "ok", "scriptName": "api", "diagnosticsChannelEvents": [], "exceptions": [], "logs": [ { "message": [ "Error parsing line:", "data: {\"completion\": \" \u5bf9\", \"stop_reason\": null, \"model\": \"claude-instant-1.1\", \"stop\": null, \"log_id\": \"a90cd1c2e5cd79dc42e5b8370db171dd7560bc1e4992f532b0788bcdc290d385\"}\r\n\r\nevent: completion\r\ndata: {\"completion\": \"\u4e0d\", \"stop_reason\": null, \"model\": \"claude-instant-1.1\", \"stop\": null, \"log_id\": \"a90cd1c2e5cd79dc42e5b8370db171dd7560bc1e4992f532b0788bcdc290d385\"}\r\n\r\nevent: ping\r\ndata: {}\r\n\r\nevent: completion\r\ndata: {\"completion\": \"\u8d77\", \"stop_reason\": null, \"model\": \"claude-instant-1.1\", \"stop\": null, \"log_id\": \"a90cd1c2e5cd79dc42e5b8370db171dd7560bc1e4992f532b0788bcdc290d385\"}\r\n\r\nevent: completion\r\ndata: {\"completion\": \",\", \"stop_reason\": null, \"model\": \"claude-instant-1.1\", \"stop\": null, \"log_id\": \"a90cd1c2e5cd79dc42e5b8370db171dd7560bc1e4992f532b0788bcdc290d385\"}\r\n\r\nevent: completion\r\ndata: {\"completion\": \"\u6211\", \"stop_reason\": null, \"model\": \"claude-instant-1.1\", \"stop\": null, \"log_id\": \"a90cd1c2e5cd79dc42e5b8370db171dd7560bc1e4992f532b0788bcdc290d385\"}\r\n\r\nevent: completion\r\ndata: {\"completion\": \"\u6ca1\u6709\", \"stop_reason\": null, \"model\": \"claude-instant-1.1\", \"stop\": null, \"log_id\": \"a90cd1c2e5cd79dc42e5b8370db171dd7560bc1e4992f532b0788bcdc290d385\"}" ], "level": "error", "timestamp": 1689694428944 }, { "message": [ "Error details:", "SyntaxError: Unexpected non-whitespace character after JSON at position 170" ], "level": "error", "timestamp": 1689694428944 }, { "message": [ "Error parsing line:", "data: {\"completion\": \"\u4e2d\", \"stop_reason\": null, \"model\": \"claude-instant-1.1\", \"stop\": null, \"log_id\": \"a90cd1c2e5cd79dc42e5b8370db171dd7560bc1e4992f532b0788bcdc290d385\"}\r\n\r\n\r\ndata: {\"completion\": \"\u65ad\", \"stop_reason\": null, \"model\": \"claude-instant-1.1\", \"stop\": null, \"log_id\": \"a90cd1c2e5cd79dc42e5b8370db171dd7560bc1e4992f532b0788bcdc290d385\"}\r\n\r\nevent: completion\r\ndata: {\"completion\": \"\u5bf9\", \"stop_reason\": null, \"model\": \"claude-instant-1.1\", \"stop\": null, \"log_id\": \"a90cd1c2e5cd79dc42e5b8370db171dd7560bc1e4992f532b0788bcdc290d385\"}\r\n\r\nevent: completion\r\ndata: {\"completion\": \"\u8bdd\", \"stop_reason\": null, \"model\": \"claude-instant-1.1\", \"stop\": null, \"log_id\": \"a90cd1c2e5cd79dc42e5b8370db171dd7560bc1e4992f532b0788bcdc290d385\"}\r\n\r\nevent: completion\r\ndata: {\"completion\": \"\u3002\", \"stop_reason\": null, \"model\": \"claude-instant-1.1\", \"stop\": null, \"log_id\": \"a90cd1c2e5cd79dc42e5b8370db171dd7560bc1e4992f532b0788bcdc290d385\"}\r\n\r\nevent: completion\r\ndata: {\"completion\": \"\u8bf7\", \"stop_reason\": null, \"model\": \"claude-instant-1.1\", \"stop\": null, \"log_id\": \"a90cd1c2e5cd79dc42e5b8370db171dd7560bc1e4992f532b0788bcdc290d385\"}\r\n\r\nevent: completion\r\ndata: {\"completion\": \"\u95ee\", \"stop_reason\": null, \"model\": \"claude-instant-1.1\", \"stop\": null, \"log_id\": \"a90cd1c2e5cd79dc42e5b8370db171dd7560bc1e4992f532b0788bcdc290d385\"}" ], "level": "error", "timestamp": 1689694429173 }, { "message": [ "Error details:", "SyntaxError: Unexpected non-whitespace character after JSON at position 169" ], "level": "error", "timestamp": 1689694429173 }, { "message": [ "Error parsing line:", "data: {\"completion\": \"\u4f60\", \"stop_reason\": null, \"model\": \"claude-instant-1.1\", \"stop\": null, \"log_id\": \"a90cd1c2e5cd79dc42e5b8370db171dd7560bc1e4992f532b0788bcdc290d385\"}\r\n\r\n\r\ndata: {\"completion\": \"\u505a\", \"stop_reason\": null, \"model\": \"claude-instant-1.1\", \"stop\": null, \"log_id\": \"a90cd1c2e5cd79dc42e5b8370db171dd7560bc1e4992f532b0788bcdc290d385\"}\r\n\r\nevent: completion\r\ndata: {\"completion\": \"\u4ec0\", \"stop_reason\": null, \"model\": \"claude-instant-1.1\", \"stop\": null, \"log_id\": \"a90cd1c2e5cd79dc42e5b8370db171dd7560bc1e4992f532b0788bcdc290d385\"}\r\n\r\nevent: completion\r\ndata: {\"completion\": \"\u4e48\", \"stop_reason\": null, \"model\": \"claude-instant-1.1\", \"stop\": null, \"log_id\": \"a90cd1c2e5cd79dc42e5b8370db171dd7560bc1e4992f532b0788bcdc290d385\"}\r\n\r\nevent: completion\r\ndata: {\"completion\": \"\u5417\", \"stop_reason\": null, \"model\": \"claude-instant-1.1\", \"stop\": null, \"log_id\": \"a90cd1c2e5cd79dc42e5b8370db171dd7560bc1e4992f532b0788bcdc290d385\"}\r\n\r\nevent: completion\r\ndata: {\"completion\": \"?\", \"stop_reason\": null, \"model\": \"claude-instant-1.1\", \"stop\": null, \"log_id\": \"a90cd1c2e5cd79dc42e5b8370db171dd7560bc1e4992f532b0788bcdc290d385\"}" ], "level": "error", "timestamp": 1689694429292 }, { "message": [ "Error details:", "SyntaxError: Unexpected non-whitespace character after JSON at position 169" ], "level": "error", "timestamp": 1689694429292 }, { "message": [ "Error parsing line:", "data: {\"completion\": \"\", \"stop_reason\": \"stop_sequence\", \"model\": \"claude-instant-1.1\", \"stop\": \"\n\nHuman:\", \"log_id\": \"a90cd1c2e5cd79dc42e5b8370db171dd7560bc1e4992f532b0788bcdc290d385\"}" ], "level": "error", "timestamp": 1689694429307 }, { "message": [ "Error details:", "SyntaxError: Bad control character in string literal in JSON at position 92" ], "level": "error", "timestamp": 1689694429307 } ], "eventTimestamp": 1689694428393, "event": { "request": { "url": "https://api.gptvpn.workers.dev//v1/chat/completions?path=v1%2Fchat%2Fcompletions", "method": "POST", "headers": { "accept-encoding": "gzip", "authorization": "REDACTED", "cache-control": "no-store", "cf-connecting-ip": "2a06:98c0:3600::103", "cf-ipcountry": "JP", "cf-ray": "7e8bc90167688a4a", "cf-visitor": "{\"scheme\":\"https\"}", "cf-worker": "cloudflare-workers.vercel-infra-production.com", "connection": "Keep-Alive", "content-length": "462", "content-type": "application/json", "host": "api.gptvpn.workers.dev", "user-agent": "Vercel Edge Functions", "x-forwarded-proto": "https", "x-middleware-subrequest": "108e1acb26c5cd85cc0ba1407b11fcd31c80186c", "x-real-ip": "2a06:98c0:3600::103", "x-vercel-id": "hnd1::jt2tb-1689694428378-8c075663a13d" }, "cf": { "longitude": "139.68990", "latitude": "35.68930", "tlsCipher": "", "continent": "AS", "asn": 16509, "country": "JP", "tlsClientAuth": { "certIssuerDNLegacy": "", "certIssuerSKI": "", "certSubjectDNRFC2253": "", "certSubjectDNLegacy": "", "certFingerprintSHA256": "", "certNotBefore": "", "certSKI": "", "certSerial": "", "certIssuerDN": "", "certVerified": "NONE", "certNotAfter": "", "certSubjectDN": "", "certPresented": "0", "certRevoked": "0", "certIssuerSerial": "", "certIssuerDNRFC2253": "", "certFingerprintSHA1": "" }, "tlsVersion": "", "colo": "NRT", "timezone": "Asia/Tokyo", "city": "Tokyo", "edgeRequestKeepAliveStatus": 1, "requestPriority": "", "httpProtocol": "HTTP/1.1", "region": "Tokyo", "regionCode": "13", "asOrganization": "Amazon.com", "postalCode": "151-0053", "botManagement": { "corporateProxy": false, "verifiedBot": false, "jsDetection": { "passed": false }, "staticResource": false, "detectionIds": {}, "score": 99 } } }, "response": { "status": 200 } }, "id": 7 }

jtsang4 commented 1 year ago

Thanks to https://github.com/jtsang4/claude-to-chatgpt/pull/27 , you can try it again.