Skip to content

Commit

Permalink
fix: Gemini 500
Browse files Browse the repository at this point in the history
  • Loading branch information
Jazee6 committed Jun 4, 2024
1 parent 1daa74c commit e1de51e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 48 deletions.
42 changes: 0 additions & 42 deletions .github/workflows/deploy.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN npm i -g pnpm@9.1.4

COPY package.json ./

#COPY patches ./patches
COPY patches ./patches

RUN pnpm install

Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ https://dash.deno.com
- Build Step改为`NITRO_PRESET=deno-deploy npm run build_node`
- Deploy Project
- 设置环境变量
- 部分地区可能需要Gemini反代

### Docker

Expand All @@ -33,7 +34,7 @@ docker run -d --name cloudflare-ai-web \
- 利用 Cloudflare Workers AI 快速搭建多模态AI平台
- 支持 Serverless 部署,无需服务器
- 支持开启访问密码,聊天记录本地存储
- 轻量化(~638 kB gzip)
- 轻量化(~646 kB gzip)
- 支持`ChatGPT` `Gemini Pro` `Stable Diffusion` `llama-3` `通义千问`

### 模型支持
Expand All @@ -54,6 +55,8 @@ https://developers.cloudflare.com/workers-ai/models/
| G_API_KEY | Google AI API Key (需要GeminiPro时填写) |
| PASSWORD | 访问密码 (可选) |

示例: 查看`.env.example`文件

#### CF_TOKEN

https://dash.cloudflare.com/profile/api-tokens
Expand All @@ -64,8 +67,6 @@ https://dash.cloudflare.com/profile/api-tokens
- 单击创建令牌
- 复制您的令牌,设置环境变量

示例:https://gateway.ai.cloudflare.com/v1/A484BCC718B10B73022BFE2D9AB49776/myai

#### CF_GATEWAY

https://dash.cloudflare.com/
Expand All @@ -74,7 +75,7 @@ https://dash.cloudflare.com/
- 添加新 AI Gateway
- 填写名称和URL slug创建
- 单击右上角API Endpoints
- 复制您的Universal Endpoint,设置环境变量
- 复制您的Universal Endpoint(去掉末尾'/'),设置环境变量

#### G_API_KEY

Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,10 @@
"highlight.js": "^11.9.0",
"markdown-it": "^14.1.0"
},
"packageManager": "pnpm@9.1.4+sha512.9df9cf27c91715646c7d675d1c9c8e41f6fce88246f1318c1aa6a1ed1aeb3c4f032fcdf4ba63cc69c4fe6d634279176b5358727d8f2cc1e65b65f43ce2f8bfb0"
"packageManager": "pnpm@9.1.4+sha512.9df9cf27c91715646c7d675d1c9c8e41f6fce88246f1318c1aa6a1ed1aeb3c4f032fcdf4ba63cc69c4fe6d634279176b5358727d8f2cc1e65b65f43ce2f8bfb0",
"pnpm": {
"patchedDependencies": {
"@google/generative-ai@0.12.0": "patches/@google__generative-ai@0.12.0.patch"
}
}
}
26 changes: 26 additions & 0 deletions patches/@google__generative-ai@0.12.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/dist/index.js b/dist/index.js
index 4290f816871d5e88e44e264fa47b2960cde864a7..64647480b2d600d8f163a15ef7ce49920b04bae5 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -241,7 +241,7 @@ class GoogleGenerativeAIRequestInputError extends GoogleGenerativeAIError {
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-const DEFAULT_BASE_URL = "https://generativelanguage.googleapis.com";
+const DEFAULT_BASE_URL = process.env.G_API_URL || "https://generativelanguage.googleapis.com";
const DEFAULT_API_VERSION = "v1beta";
/**
* We can't `require` package.json if this runs on web. We will use rollup to
diff --git a/dist/index.mjs b/dist/index.mjs
index aabb1c97ad6ec5af1e8e736da9d3dc23c478cb09..b02db137b30e5f77e7a5d68657b1fbc19581c8f2 100644
--- a/dist/index.mjs
+++ b/dist/index.mjs
@@ -239,7 +239,7 @@ class GoogleGenerativeAIRequestInputError extends GoogleGenerativeAIError {
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-const DEFAULT_BASE_URL = "https://generativelanguage.googleapis.com";
+const DEFAULT_BASE_URL = process.env.G_API_URL || "https://generativelanguage.googleapis.com";
const DEFAULT_API_VERSION = "v1beta";
/**
* We can't `require` package.json if this runs on web. We will use rollup to

0 comments on commit e1de51e

Please sign in to comment.