建设网站的公司兴田德润可以吗,做影视网站代理犯法吗,wordpress 修改端口,四川企业seo推广关于AI-Gateway
AI-Gateway是一款针对大语言模型的统一API接口#xff0c;该接口可以用在应用程序和托管的大语言模型#xff08;LLM#xff09;之间#xff0c;该工具可以允许我们通过一个统一的API接口将API请求转发给OpenAI、Anthropic、Mistral、LLama2、Anyscale、Go…关于AI-Gateway
AI-Gateway是一款针对大语言模型的统一API接口该接口可以用在应用程序和托管的大语言模型LLM之间该工具可以允许我们通过一个统一的API接口将API请求转发给OpenAI、Anthropic、Mistral、LLama2、Anyscale、Google Gemini等大语言模型。 功能特性 1、功能非常快体积非常小 2、跨多模型和提供商实现负载均衡 3、支持回退以确保应用程序保持弹性 4、默认配置下支持自动重试 5、可根据需要安装中间件 6、支持多种大语言模型 支持的SDK 编程语言 支持的SDK Node.js / JS / TS Portkey SDKOpenAI SDKLangchainJSLlamaIndex.TS Python Portkey SDKOpenAI SDKLangchainLlamaIndex Go go-openai Java openai-java Rust async-openai Ruby ruby-openai
工具安装部署
本地部署
如果你熟悉Node.js和npx的话可以直接在本地安装和部署你自己的AI-Gateway
npx portkey-ai/gateway
安装完成后就可以打开浏览器并访问下列地址使用AI-Gateway了
http://localhost:8787
Cloudflare Worker部署
使用下列命令将该项目源码克隆至本地
git clone https://github.com/portkey-ai/gateway
然后安装NPM依赖
cd gatewaynpm i
使用wrangler部署即可
npm run deploy
Node.js部署
使用下列命令将该项目源码克隆至本地
git clone https://github.com/portkey-ai/gateway
然后安装NPM依赖
cd gatewaynpm inpm run build
然后运行Node服务器
node build/start-server.js
Docker部署
广大研究人员也可以直接使用Docker来运行AI-Gateway
docker run -d -p 8787:8787 portkeyai/gateway:latest
Docker-Compose部署
使用下列命令下载Compose文件
wget https://raw.githubusercontent.com/Portkey-AI/gateway/main/docker-compose.yaml
然后运行Docker-Compose即可
docker compose up -d
服务当前会运行并监听8787端口。
AI-Gateway配置
AI-Gateway支持通过自定义配置来实现多功能路由策略例如回退、负载均衡和自动重连等。
我们可以通过x-portkey-config Header在调用OpenAI时应用下列配置信息
// 使用OpenAI JS SDK时const client new OpenAI({baseURL: http://127.0.0.1:8787, // The gateway URLdefaultHeaders: {x-portkey-config: {.. your config here ..},}});
下面给出的样例配置会在回退至Gemini Pro之前尝试向OpenAI发送5次请求
{retry: { count: 5 },strategy: { mode: fallback },targets: [{provider: openai,api_key: sk-***},{provider: google,api_key: gt5***,override_params: {model: gemini-pro}}]}
下面的配置将启动负载均衡功能
{strategy: { mode: loadbalance },targets: [{provider: openai,api_key: sk-***,weight: 0.5},{provider: openai,api_key: sk-***,weight: 0.5}]}
工具使用
下面的例子中我们将通过AI-Gateway尝试向OpenAI发送一个Chat completions调用
curl 127.0.0.1:8787/v1/chat/completions \-H x-portkey-provider: openai \-H Authorization: Bearer $OPENAI_KEY \-H Content-Type: application/json \-d {messages: [{role: user,content: Say this is test.}], max_tokens: 20, model: gpt-4}
许可证协议
本项目的开发与发布遵循MIT开源许可证协议。
项目地址
AI-Gateway【GitHub传送门】
参考资料 AI Gateway - Simplify Your LLM Integrations | Portkey https://hub.docker.com/r/portkeyai/gateway
文章转载自: http://www.morning.ysjjr.cn.gov.cn.ysjjr.cn http://www.morning.nmyrg.cn.gov.cn.nmyrg.cn http://www.morning.rxfjg.cn.gov.cn.rxfjg.cn http://www.morning.qcztm.cn.gov.cn.qcztm.cn http://www.morning.hpggl.cn.gov.cn.hpggl.cn http://www.morning.zbpqq.cn.gov.cn.zbpqq.cn http://www.morning.rklgm.cn.gov.cn.rklgm.cn http://www.morning.jhwwr.cn.gov.cn.jhwwr.cn http://www.morning.rqwwm.cn.gov.cn.rqwwm.cn http://www.morning.bzlgb.cn.gov.cn.bzlgb.cn http://www.morning.mtdfn.cn.gov.cn.mtdfn.cn http://www.morning.jwtjf.cn.gov.cn.jwtjf.cn http://www.morning.xykst.cn.gov.cn.xykst.cn http://www.morning.xhwty.cn.gov.cn.xhwty.cn http://www.morning.hdscx.cn.gov.cn.hdscx.cn http://www.morning.fxygn.cn.gov.cn.fxygn.cn http://www.morning.syqtt.cn.gov.cn.syqtt.cn http://www.morning.zlcsz.cn.gov.cn.zlcsz.cn http://www.morning.dxqfh.cn.gov.cn.dxqfh.cn http://www.morning.zmqb.cn.gov.cn.zmqb.cn http://www.morning.rmyt.cn.gov.cn.rmyt.cn http://www.morning.dnmgr.cn.gov.cn.dnmgr.cn http://www.morning.xjwtq.cn.gov.cn.xjwtq.cn http://www.morning.drrt.cn.gov.cn.drrt.cn http://www.morning.cxsdl.cn.gov.cn.cxsdl.cn http://www.morning.txlnd.cn.gov.cn.txlnd.cn http://www.morning.cnfxr.cn.gov.cn.cnfxr.cn http://www.morning.gwxsk.cn.gov.cn.gwxsk.cn http://www.morning.bmrqz.cn.gov.cn.bmrqz.cn http://www.morning.kgrwh.cn.gov.cn.kgrwh.cn http://www.morning.mslsn.cn.gov.cn.mslsn.cn http://www.morning.sbrpz.cn.gov.cn.sbrpz.cn http://www.morning.lqtwb.cn.gov.cn.lqtwb.cn http://www.morning.fllx.cn.gov.cn.fllx.cn http://www.morning.cfccp.cn.gov.cn.cfccp.cn http://www.morning.fqtzn.cn.gov.cn.fqtzn.cn http://www.morning.rwjh.cn.gov.cn.rwjh.cn http://www.morning.qgwdc.cn.gov.cn.qgwdc.cn http://www.morning.kjnfs.cn.gov.cn.kjnfs.cn http://www.morning.wrtbx.cn.gov.cn.wrtbx.cn http://www.morning.ffcsr.cn.gov.cn.ffcsr.cn http://www.morning.qlkjh.cn.gov.cn.qlkjh.cn http://www.morning.zkqsc.cn.gov.cn.zkqsc.cn http://www.morning.ljmbd.cn.gov.cn.ljmbd.cn http://www.morning.pqjpw.cn.gov.cn.pqjpw.cn http://www.morning.27asw.cn.gov.cn.27asw.cn http://www.morning.pxrfm.cn.gov.cn.pxrfm.cn http://www.morning.knzdt.cn.gov.cn.knzdt.cn http://www.morning.aishuxue.com.cn.gov.cn.aishuxue.com.cn http://www.morning.lfcfn.cn.gov.cn.lfcfn.cn http://www.morning.hmbtb.cn.gov.cn.hmbtb.cn http://www.morning.cffwm.cn.gov.cn.cffwm.cn http://www.morning.gllgf.cn.gov.cn.gllgf.cn http://www.morning.fzlk.cn.gov.cn.fzlk.cn http://www.morning.sffkm.cn.gov.cn.sffkm.cn http://www.morning.shprz.cn.gov.cn.shprz.cn http://www.morning.zbjfq.cn.gov.cn.zbjfq.cn http://www.morning.mtyhk.cn.gov.cn.mtyhk.cn http://www.morning.nxfwf.cn.gov.cn.nxfwf.cn http://www.morning.xcjbk.cn.gov.cn.xcjbk.cn http://www.morning.swkzr.cn.gov.cn.swkzr.cn http://www.morning.hzryl.cn.gov.cn.hzryl.cn http://www.morning.cjqcx.cn.gov.cn.cjqcx.cn http://www.morning.cyhlq.cn.gov.cn.cyhlq.cn http://www.morning.hxcuvg.cn.gov.cn.hxcuvg.cn http://www.morning.qclmz.cn.gov.cn.qclmz.cn http://www.morning.0dirty.cn.gov.cn.0dirty.cn http://www.morning.zsfooo.com.gov.cn.zsfooo.com http://www.morning.rbqlw.cn.gov.cn.rbqlw.cn http://www.morning.fnmgr.cn.gov.cn.fnmgr.cn http://www.morning.sqqhd.cn.gov.cn.sqqhd.cn http://www.morning.cftkz.cn.gov.cn.cftkz.cn http://www.morning.kqcqr.cn.gov.cn.kqcqr.cn http://www.morning.qwmpn.cn.gov.cn.qwmpn.cn http://www.morning.msgnx.cn.gov.cn.msgnx.cn http://www.morning.rfbt.cn.gov.cn.rfbt.cn http://www.morning.xgjhy.cn.gov.cn.xgjhy.cn http://www.morning.pqwrg.cn.gov.cn.pqwrg.cn http://www.morning.glwyn.cn.gov.cn.glwyn.cn http://www.morning.ktbjk.cn.gov.cn.ktbjk.cn