Skip to content

Commit

Permalink
2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Jazee6 committed Apr 3, 2024
1 parent f5e2ce7 commit 128ce17
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 90 deletions.
42 changes: 0 additions & 42 deletions .github/workflows/deploy.yml

This file was deleted.

32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@

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

### Deno Deploy

https://dash.deno.com

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

### Docker

```bash
Expand All @@ -21,16 +30,15 @@ docker run -d --name cloudflare-ai-web \

## 特性

- 利用 Cloudflare Workers AI 快速搭建AI聊天、AI翻译、AI绘画平台
- Vercel Edge Functions 部署,全球边缘网络加速,500000次免费额度,无限制响应时间
- 支持 ChatGPT GeminiPro(Vision),支持开启访问密码,支持自定义域名
- 利用 Cloudflare Workers AI 快速搭建多模态AI平台
- 支持 Serverless 部署,无需服务器
- 支持开启访问密码,聊天记录本地存储
- 轻量化(~638 kB gzip)
- 支持`ChatGPT` `Gemini Pro`

### 模型支持

- 视觉 `GeminiPro Vision`
- 文生图 `stable-diffusion-xl-base-1.0` `dreamshaper-8-lcm`
- 聊天 `GeminiPro` `gpt-3.5-turbo` `qwen1.5-14b-chat-awq`
- 翻译 `m2m100-1.2b`
https://developers.cloudflare.com/workers-ai/models/

## 部署说明

Expand All @@ -53,7 +61,7 @@ https://dash.cloudflare.com/profile/api-tokens
- 使用Workers AI (Beta)模板
- 单击继续以显示摘要
- 单击创建令牌
- 复制您的令牌,在vercel中设置环境变量
- 复制您的令牌,设置环境变量

#### CF_GATEWAY

Expand All @@ -63,7 +71,7 @@ https://dash.cloudflare.com/
- 添加新 AI Gateway
- 填写名称和URL slug创建
- 单击右上角API Endpoints
- 复制您的Universal Endpoint,在vercel中设置环境变量
- 复制您的Universal Endpoint,设置环境变量

#### G_API_KEY

Expand All @@ -83,12 +91,6 @@ nitro: {
}
```

## Tips

- 由于Workers AI 目前为开放 Beta 版,不建议用于生产数据和流量,限制 + 访问可能会发生变化
- 请不要启用AI Gateway的缓存,否则可能会导致重复的回复
- 请保持与Main分支同步,以便获取最新的功能和修复

## Star History

[![Star History Chart](https://api.star-history.com/svg?repos=Jazee6/cloudflare-ai-web&type=Date)](https://star-history.com/#Jazee6/cloudflare-ai-web&Date)
3 changes: 1 addition & 2 deletions components/Sidebar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import type {TabItem} from "~/utils/db";
import {useGlobalState} from "~/utils/store";
const {openAside, openSettings} = useGlobalState()
Expand All @@ -26,7 +25,7 @@ defineProps<{
{{ i.label }}
</div>
<UIcon name="i-heroicons-trash" v-if="i.id === selected" @click="handleDelete(i.id)"
class="w-6 hover:bg-red-500 transition-all"/>
class="shrink-0 hover:bg-red-500 transition-all"/>
</li>
</ol>
<div class="flex my-1">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cloudflare-ai-web",
"version": "2.0 beta",
"version": "2.0",
"private": true,
"type": "module",
"scripts": {
Expand Down
6 changes: 6 additions & 0 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ onMounted(async () => {
})
async function handleNewChat() {
if (loading.value) return
await initDB()
history.value = []
Expand All @@ -67,6 +69,8 @@ async function handleNewChat() {
}
async function handleSwitchChat(e: MouseEvent) {
if (loading.value) return
const target = e.target as HTMLElement
const id = target.dataset.id
if (!id) return
Expand All @@ -78,6 +82,8 @@ async function handleSwitchChat(e: MouseEvent) {
}
async function handleDelete(id: number) {
if (loading.value) return
if (tabs.value.length === 1) return
tabs.value = tabs.value.filter(i => i.id !== id)
DB.deleteTabAndHistory(id)
Expand Down
40 changes: 10 additions & 30 deletions utils/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,43 +65,23 @@ export const textGenModels: Model[] = [{
endpoint: 'chat/completions',
type: 'chat'
}, {
id: '@cf/meta/llama-2-7b-chat-fp16',
name: 'llama-2-7b-chat-fp16',
id: '@cf/qwen/qwen1.5-14b-chat-awq',
name: 'qwen1.5-14b-chat-awq',
provider: 'workers-ai',
type: 'chat'
}, {
id: '@cf/meta/llama-2-7b-chat-int8',
name: 'llama-2-7b-chat-int8',
provider: 'workers-ai',
type: 'chat'
}, {
id: '@cf/mistral/mistral-7b-instruct-v0.1',
name: 'mistral-7b-instruct-v0.1',
provider: 'workers-ai',
type: 'chat'
}, {
id: '@cf/thebloke/discolm-german-7b-v1-awq',
name: 'discolm-german-7b-v1-awq',
provider: 'workers-ai',
type: 'chat'
}, {
id: '@cf/tiiuae/falcon-7b-instruct',
name: 'falcon-7b-instruct',
provider: 'workers-ai',
type: 'chat'
}, {
id: '@hf/thebloke/llama-2-13b-chat-awq',
name: 'llama-2-13b-chat-awq',
id: '@cf/openchat/openchat-3.5-0106',
name: 'openchat-3.5-0106',
provider: 'workers-ai',
type: 'chat'
}, {
id: '@hf/thebloke/llamaguard-7b-awq',
name: 'llamaguard-7b-awq',
id: '@cf/google/gemma-7b-it-lora',
name: 'gemma-7b-it-lora',
provider: 'workers-ai',
type: 'chat'
}, {
id: '@hf/thebloke/mistral-7b-instruct-v0.1-awq',
name: 'mistral-7b-instruct-v0.1-awq',
id: '@hf/thebloke/openhermes-2.5-mistral-7b-awq',
name: 'openhermes-2.5-mistral-7b-awq',
provider: 'workers-ai',
type: 'chat'
}, {
Expand All @@ -110,8 +90,8 @@ export const textGenModels: Model[] = [{
provider: 'workers-ai',
type: 'chat'
}, {
id: '@cf/openchat/openchat-3.5-0106',
name: 'openchat-3.5-0106',
id: '@hf/nexusflow/starling-lm-7b-beta',
name: 'starling-lm-7b-beta',
provider: 'workers-ai',
type: 'chat'
}]
Expand Down

0 comments on commit 128ce17

Please sign in to comment.