wpv-chan / cf-copilot-service Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
关联:aaamoon/copilot-gpt4-service#51
经过后端加日志分析,发现发送请求头为:Content-Type: application/json
时,仍然按照text/event-stream; charset=utf-8
发送,导致前端接收为空,因此无法生成标题。
如题,自己部署了一份程序,将接口和Token填入ChatGPT-Next-Web,可以正常使用,但使用python本地请求,返回的就是空值,代码如下:
import requests
url = "https://XXX/v1/chat/completions"
payload = {
"model": "gpt-4",
"messages": [
{
"role": "user",
"content": "讲个笑话"
}
],
}
headers = {
'Authorization': 'Bearer XXX',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, json=payload)
# print(response.status_code)
print(response.text)
测试服务报错:
JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
(也许)原因:沉浸式翻译需要返回 JSON 而非 event stream
(我手上没有 OpenAI 的 api key 或者文档,不太清楚返回的 JSON 应该是什么格式,否则我大概可以自己来修)
更新:已经修了,需要的话我随时 pr
error: fail to fetch
未知原因
若缺少 object 和 model,会导致一些第三方服务无法正常使用。
这是 OpenAI 官方响应示例 https://platform.openai.com/docs/api-reference/chat/object
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "gpt-3.5-turbo",
"system_fingerprint": "fp_44709d6fcb",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "\n\nHello there, how may I assist you today?",
},
"logprobs": null,
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21
}
}
目前项目的响应
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "这个机器人杀了一个人。",
"role": "assistant"
}
}
],
"created": 1704551141,
"id": "chatcmpl-8e1uHljGAv0bxOVtasAeytlRw3aqT",
"usage": {
"completion_tokens": 11,
"prompt_tokens": 33,
"total_tokens": 44
}
}
按照 README 在 Cloudflare Worker 中部署完成,但无法使用。在 ChatGPT-Next-Web 和沉浸式翻译配置都提示 500: Missing or malformed Authorization header
。直接访问 Cloudflare Worker 的 Endpoint https://cf-copilot-service. cloudflareusername.workers.dev
显示如下:
{"object":"list","data":[{"id":"gpt-4","object":"model","created":1687882411,"owned_by":"openai"},{"id":"gpt-3.5-turbo","object":"model","created":1677610602,"owned_by":"openai"}]}
下图是 Cloudflare Worker 中的数据截图。
同一个 GitHub Copilot token 可以在 https://gpt4copilot.tech 中正常使用。请问这是什么原因,求解答一下,谢谢。
Related: aaamoon/copilot-gpt4-service#36
用了脚本之后,我封了两个学生包号了!!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.