Git Product home page Git Product logo

cloudflare-ai-web's Introduction

cloudflare-ai-web

AI 启动!

一键部署(推荐)

Deploy with Vercel

示例:https://ai.jaze.top

Deno Deploy

https://dash.deno.com

  • Fork 本仓库
  • Build Step改为NITRO_PRESET=deno-deploy npm run build_node
  • Deploy Project
  • 设置环境变量

Docker

docker run -d --name cloudflare-ai-web \
  -e CF_TOKEN=YOUR_CF_TOKEN \
  -e CF_GATEWAY=YOUR_CF_GATEWAY \
  -p 3000:3000 \
  --restart=always \
  jazee6/cloudflare-ai-web

特性

  • 利用 Cloudflare Workers AI 快速搭建多模态AI平台
  • 支持 Serverless 部署,无需服务器
  • 支持开启访问密码,聊天记录本地存储
  • 轻量化(~638 kB gzip)
  • 支持ChatGPT Gemini Pro

模型支持

https://developers.cloudflare.com/workers-ai/models/

部署说明

环境变量列表

名称 描述
CF_TOKEN Cloudflare Workers AI Token
CF_GATEWAY Cloudflare AI Gateway URL
OPENAI_API_KEY OpenAI API Key (需要ChatGPT时填写)
G_API_KEY Google AI API Key (需要GeminiPro时填写)
G_API_URL Google AI 反代 (非美国ip填写,或参考以下配置)
PASSWORD 访问密码 (可选)

CF_TOKEN

https://dash.cloudflare.com/profile/api-tokens

  • 单击创建令牌
  • 使用Workers AI (Beta)模板
  • 单击继续以显示摘要
  • 单击创建令牌
  • 复制您的令牌,设置环境变量

CF_GATEWAY

https://dash.cloudflare.com/

  • Cloudflare 侧栏 AI - AI Gateway
  • 添加新 AI Gateway
  • 填写名称和URL slug创建
  • 单击右上角API Endpoints
  • 复制您的Universal Endpoint,设置环境变量

G_API_KEY

https://ai.google.dev/tutorials/rest_quickstart#set_up_your_api_key

G_API_URL

参考 https://github.com/Jazee6/gemini-proxy 搭建反代

或者在nuxt.config.ts中添加以下配置

nitro: {
    vercel: {
        regions: ["cle1", "iad1", "pdx1", "sfo1", "sin1", "syd1", "hnd1", "kix1"]
    }
}

Star History

Star History Chart

cloudflare-ai-web's People

Contributors

deno-deploy[bot] avatar jazee6 avatar roshanca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cloudflare-ai-web's Issues

增加在cloudflare page 部署教程

对于vercel可能在部分地区被污染,因此增加在page部署的方法,同样简单方便
以下是我的构建命令
Build command:
npx nuxt generate
Build output directory:
/dist
Root directory:
/
Build comments on pull requests:
Enabled

在使用vercel部署后使用,报了两个错,麻烦各位大佬帮忙看看。

在使用vercel部署后使用,报了两个错,麻烦各位大佬帮忙看看。
1.首先,因为部署代理的链接不可用,因此采用了修改nuxt.config.ts文件的方法,修改后如下,不知是否对不对?

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
    devtools: {enabled: true},
    modules: ['@nuxt/ui'],
    css: ['~/assets/css/style.css'],
    devServer: {
        port: 3001,
    },
    routeRules: {
        '/': {
            prerender: true,
        }
    },
    app: {
        head: {
            title: 'CF AI Web',
            meta: [
                {
                    name: 'keywords',
                    content: 'CF AI Web, AI, Cloudflare Workers, ChatGPT, GeminiPro, Google Generative AI'
                },
                {
                    name: 'description',
                    content: 'Integrated web platform supporting GeminiPro/Cloudflare Workers AI/ChatGPT by Jazee6'
                }
            ]
        }
    }
})

nitro: {
    vercel: {
        regions: ["cle1", "iad1", "pdx1", "sfo1", "sin1", "syd1", "hnd1", "kix1"]
    }
}

2.环境变量添加了gemini api key,现在报错代码如下。

[POST] /api/auth/gemini/?model=gemini-pro status=500

[nuxt] [request error] [unhandled] [500] [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1/models/gemini-pro:streamGenerateContent?alt=sse: [400 Bad Request] User location is not supported for the API use.
  at (index.mjs:1:117483)  
  at (index.mjs:1:121866)

[Bug] GeminiPro Vision

GeminiPro Vision 对于中文问题无响应,而且同一个对话不能上传第二张图片。

image

CF AI转换成openai格式

建议专注在把CF AI转换成openai格式,这样就可以接入One-API配合其他成熟的前端应用使用。

反代配置问题

安照大佬项目的指引,基本搭建成功,能跑起来了。目前唯一的问题是gemini pro 出现地区不支持问题,大佬项目里说到:
或者在nuxt.config.ts中添加以下配置

nitro: {
vercel: {
regions: ["cle1", "iad1", "pdx1", "sfo1", "sin1", "syd1", "hnd1", "kix1"]
}
}

本人小白,找了半天不知道在哪里添加这个内容,麻烦大佬再具体指导一下(如果能截图说明更好),谢谢!

求助

[可以正常使用了

请问这个 API_KEY_INVALID 是什么原因呢?已经填写刚申请的Gemini key 了

[nuxt] [request error] [unhandled] [500] [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1/models/gemini-pro:streamGenerateContent?alt=sse: [400 Bad Request] API key not valid. Please pass a valid API key. [{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"API_KEY_INVALID","domain":"googleapis.com","metadata":{"service":"generativelanguage.googleapis.com"}}]
at (index.mjs:1:117486)
at (index.mjs:1:121869)

为什么我的输入对话框位置不在底部?

如图,我的输入框位置跑到**去了,试过强制刷新、隐私模式还是一样
iShot_2024-03-21_14 28 25

另外我对比了一下,使用 vercel 随机分配的域名显示正常的,底部也有版本信息。绑定自定义域名(托管在 cf)就显示不正常了
iShot_2024-03-21_14 34 19

希望增加gemini-1.5-pro-latest模型

默认的 gemini pro 不知道是啥版本,很笨,不太好用。最近谷歌已经开放gemini-1.5-pro的 api 申请了,我两个谷歌账号都申请成功了,应该还比较容易。希望可以增加gemini-1.5-pro-latest模型。

Gemini 1.5 Pro Waitlist申请地址
https://aistudio.google.com/app/waitlist/97445851

附上谷歌回复的邮件参考,调用地址是/v1beta,模型名是gemini-1.5-pro-latest

Gemini 1.5 Pro API
You should now have API access to Gemini 1.5 Pro on the GCP project you shared with us!
To get started:
Create an API key generated from your allowlisted GCP Project.
Run the list_models Python method or this cURL command:
curl 'https://generativelanguage.googleapis.com/v1beta/models?key=<YOUR_API_KEY>'
Check out our Gemini API cookbook or visit the Gemini API docs, open up the Python quickstart (or the programming language of your choice) and update code by replacing the model name with 'gemini-1.5-pro-latest'.
Having access issues? Go to https://aistudio.google.com/app/apikey and confirm that the API key you are using is tied to your allowlisted Google Cloud Project.

可以添加识别生图参数的功能吗?

Stable Diffusion XL应该除了Prompt还可以识别别的一些参数:其所有的参数应该是按照官网上来的:
https://platform.stability.ai/docs/features/api-parameters。
大概常用的参数有:
prompt:正常提示词
height:图片的高度
width: 图片的宽度
steps: 迭代步数
num_samples: 一次性生图的个数
cfg_scale: 提示词的权重
sampler:采样器函数名称,例如k_euler就是euler采样器
seed: 种子,默认为随机(0)

可以通过一个函数来解析聊天message里面是否包含“--width”这种参数来识别是否用户添加了参数,然后将参数解析为一个请求体,发送给SDXL模型。例如聊天内容为“ a cute cat --width 1200 --height 1280" 就可以解析为:

{
prompt:'a cute cat',
width:1200,
height:1280
}

Build Step在哪里

Build Step改为NITRO_PRESET=deno-deploy npm run build_node
这一步是在哪里修改

能不能取消未响应时间

经常提示504 {"result":null,"success":false,"errors":[{"code":7009,"message":"Upstream service unavailable"}],"messages":[]}

只要十秒内没有生成就报这个,有些问题十秒钟输出不完的

请问openai的key使用one-api的是否可以,另外one-api的接口地址变量是openai_api_url吗?

OPENAI_API_KEY添加了one-api的key。增加了一个OPENAI_API_URL填写了one-api的代理地址,但是chatgpt-3.5没有回应。
使用vercel搭建。是否只能使用官方key

Error: recieved non-200 status code, {"status":401,"statusText":"Unauthorized","body":"{\n "error": {\n "message": "Incorrect API key provided: sk-TK6NM***************************************48B5. You can find your API key at https://platform.openai.com/account/api-keys.\",\n "type": "invalid_request_error",\n "param": null,\n "code": "invalid_api_key"\n }\n}\n"}

i18n

hi, is there any plans to add English support?

Thanks,

所有问题,都是返回500

您好,请问这是什么原因?
一键部署在Vercel上,界面正常,没有用其他API,只是Gremini. 谢谢。

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.