linlin00000000 / vercel-proxy-openai Goto Github PK
View Code? Open in Web Editor NEW使用 Vercel 代理 openai
使用 Vercel 代理 openai
Retrying langchain.chat_models.openai.ChatOpenAI.completion_with_retry.._completion_with_retry in 1.0 seconds as it raised APIError: Invalid response object from API: 'An error occurred with this application.\n\nROUTER_EXTERNAL_TARGET_ERROR\n' (HTTP response code was 502).
请问这个和通过vercel转发有关系么
用apifox 调用会出现
An error occurred with this application.
ROUTER_EXTERNAL_TARGET_ERROR
您好,我在按您的教程配置完成后仍然出现了如下问题,想咨询一下解决方案:
openai.error.InvalidRequestError: Invalid URL (POST/v1/chat/completions/chat/completions)
代码如下:
import openai
openai.api_key = "****"
host = '*****'
url = f'https://{host}/v1/chat/completions'
openai.api_base = url
messages = [
{"role": "system", "content": "You are a news creator"},
{"role": "user",
"content": f"Write a news article with the title 你好 that spans 3-4 paragraphs and comprehensively covers pertinent and vital information on the topic. Your piece should be both informative and engaging, capturing readers' attention and keeping them informed throughout."},
]
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=messages
)
print(completion.choices[0].message["content"]
部署成功,也能访问,但python调用时候要翻墙
{
"error": {
"message": "Invalid URL (GET /)",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
{
"rewrites": [
{ "source": "/", "destination": "https://api.openai.com" },
{
"source": "/:match*",
"destination": "https://api.openai.com/:match*"
}
],
"github": {
"silent": true
},
"regions": [
"arn1",
"bom1",
"cdg1",
"cle1",
"cpt1",
"dub1",
"fra1",
"gru1",
// "hkg1", ip blocked by openai
"hnd1",
"iad1",
"icn1",
"kix1",
"lhr1",
"pdx1",
"sfo1",
"sin1",
"syd1"
]
}
在 vercel 部署的服务是否支持流式,我看vercel 上好像本身有限制
放在.env中可以么
比如
原始调用方法是
import openai
openai.api_key = api
chat = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=messages,
max_tokens=400,
)
这段代码是不是修改成
import openai
openai.api_key = api
host = 'YOUR DOMAIN'
url=`https://${host}/v1/chat/completions`
openai.api_base= url
chat = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=messages,
max_tokens=400,
)
我看到请求都是对话转发,支持embedding 吗?
按大神您 的教程,部署了项目,并把自己的一个域名绑上去了,但当我访问openai的特定接口路径(如/v1/models,在浏览器中通过openai.com的域名是可以正常访问的),提示页面没找到。看现象,感觉是反向代理没有生效?请问是什么原因。补充:已经把vercel.json文件提交到github里面。
部署成功了,但是很慢,很多都会报错,如何提高速度
纯小白,自己会照葫芦画瓢。
使用方法
访问 openai api 时,将 "api.openai.com" 换成你的自定义域名,例如
const host = 'YOUR DOMAIN'
const url = https://${host}/v1/chat/completions
在其他 chatgpt 项目中,可以将变量 "OPENAI_API_BASE_URL" 设置为你的域名
我在别人开发好的项目里填入域名都无法成功,和我没操作第一条有关系吗?谢谢
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.