admin管理员组文章数量:1794759
无服务器部署ChatGPT聊天界面
使用Cloudflare部署Ai聊天前端界面,无需置备服务器,只要一个可以接入cloudflare的域名即可。
代码摘自开源项目
功能介绍
支持基于gpt-3.5-turbo模型的对话 支持批量查询api到期时间和剩余额度
安装步骤
将代码部署到Cloudflare的worker平台(其他支持worker的平台也可)
代码语言:javascript代码运行次数:0运行复制/**
* @auther Rehiy
* @url
*/
const GITHUB_URL = '';
async function github_proxy(request) {
const url = new URL(request.url);
let backend = GITHUB_URL + url.pathname;
if (url.pathname.endsWith('/')) {
backend += 'index.html';
}
const res = await fetch(backend, {
method: request.method,
headers: {
'User-Agent': request.headers.get('User-Agent'),
},
});
const headers = new Headers();
headers.set('Content-Type', file_type(backend));
headers.set('Cache-Control', 'public, max-age=86400');
return new Response(res.body, {
status: res.status,
headers,
});
}
function file_type(url) {
const ext = url.split('?').shift().split('.').pop();
const mines = {
'json': 'application/json',
'js': 'application/javascript',
'css': 'text/css',
'xml': 'text/xml',
'html': 'text/html',
'webm': 'video/webm',
'mp3': 'audio/mpeg',
'mp4': 'video/mp4',
'webp': 'image/webp',
'gif': 'image/gif',
'png': 'image/png',
'jpg': 'image/jpeg',
'jpeg': 'image/jpeg',
'svg': 'image/svg+xml',
'ico': 'image/x-icon',
};
return mines[ext] || 'text/plain';
}
// esmodule
export default {
async fetch(request, env) {
return github_proxy(request);
}
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。 原始发表:2023-07-06,如有侵权请联系 cloudcommunity@tencent 删除chatgpt部署服务器域名开源本文标签: 无服务器部署ChatGPT聊天界面
版权声明:本文标题:无服务器部署ChatGPT聊天界面 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1755045132a1709823.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论