GeminiProChat icon indicating copy to clipboard operation
GeminiProChat copied to clipboard

无论如何配置代理,都得到以下反馈:Error [GoogleGenerativeAI Error]: Error fetching from fetch failed

Open GODGOD126 opened this issue 2 years ago • 4 comments

What operating system are you using?

Windows

What browser are you using?

chrome

Describe the bug

请教!

What prompt did you enter?

No response

Console Logs

astro v2.7.0 started in 445ms

┃ Local http://localhost:3000/ ┃ Network use --host to expose

TypeError: fetch failed at Object.fetch (node:internal/deps/undici/undici:11730:11) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async makeRequest (file:///F:/%E5%B9%BC%E5%B8%88%E5%AE%9D%E7%BD%91%E9%A1%B5%E7%89%88/GeminiProChat/node_modules/.pnpm/@[email protected]/node_modules/@fuyun/generative-ai/dist/index.mjs:184:20) at async generateContentStream (file:///F:/%E5%B9%BC%E5%B8%88%E5%AE%9D%E7%BD%91%E9%A1%B5%E7%89%88/GeminiProChat/node_modules/.pnpm/@[email protected]/node_modules/@fuyun/generative-ai/dist/index.mjs:503:22) node:internal/process/promises:289 triggerUncaughtException(err, true /* fromPromise */); ^

TypeError: fetch failed at Object.fetch (node:internal/deps/undici/undici:11730:11) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async makeRequest (file:///F:/%E5%B9%BC%E5%B8%88%E5%AE%9D%E7%BD%91%E9%A1%B5%E7%89%88/GeminiProChat/node_modules/.pnpm/@[email protected]/node_modules/@fuyun/generative-ai/dist/index.mjs:184:20) at async generateContentStream (file:///F:/%E5%B9%BC%E5%B8%88%E5%AE%9D%E7%BD%91%E9%A1%B5%E7%89%88/GeminiProChat/node_modules/.pnpm/@[email protected]/node_modules/@fuyun/generative-ai/dist/index.mjs:503:22)

Node.js v20.10.0  ELIFECYCLE  Command failed with exit code 1.

Participation

  • [ ] I am willing to submit a pull request for this issue.

GODGOD126 avatar Dec 19 '23 01:12 GODGOD126

你如果是境内本地开发,需要带上环境变量。

GEMINI_API_KEY={YOUR_TOKEN} API_BASE_URL={YOUR_API_BASE_URL} pnpm run dev
# 例:GEMINI_API_KEY=abc12345678 API_BASE_URL=https://xxxx.vercel.app pnpm run dev

antergone avatar Dec 19 '23 05:12 antergone

你如果是境内本地开发,需要带上环境变量。

GEMINI_API_KEY={YOUR_TOKEN} API_BASE_URL={YOUR_API_BASE_URL} pnpm run dev
# 例:GEMINI_API_KEY=abc12345678 API_BASE_URL=https://xxxx.vercel.app pnpm run dev

非常感谢您的回答,我在vercel上部署了该项目,然后在.env里将vercel给的URL作为API_BASE_URL,如下:API_BASE_URL=https://youshibao-godgod126s-projects.vercel.app

不过还是得到“Fetch Fail”的反馈,跟Chatgpt 4.0对话了一天也没有解决。。。

  1. 合并当前项目最新代码,几天前的版本.env识别是有缺陷的 修复详见: https://github.com/babaohuang/GeminiProChat/pull/24 https://github.com/babaohuang/GeminiProChat/pull/25

  2. 如果你是Vercel部署,可以不使用.env文件,使用Vercel Project的环境变量即可。

  3. 注意API_BASE_URL指的是你反向代理Google PaLM API的地址,不是你自己搭建GeminiProChat的地址 反向代理的搭建:https://simonmy.com/posts/使用vercel反向代理google-palm-api.html

antergone avatar Dec 20 '23 10:12 antergone

你如果是境内本地开发,需要带上环境变量。

GEMINI_API_KEY={YOUR_TOKEN} API_BASE_URL={YOUR_API_BASE_URL} pnpm run dev
# 例:GEMINI_API_KEY=abc12345678 API_BASE_URL=https://xxxx.vercel.app pnpm run dev

非常感谢您的回答,我在vercel上部署了该项目,然后在.env里将vercel给的URL作为API_BASE_URL,如下:API_BASE_URL=https://youshibao-godgod126s-projects.vercel.app 不过还是得到“Fetch Fail”的反馈,跟Chatgpt 4.0对话了一天也没有解决。。。

  1. 合并当前项目最新代码,几天前的版本.env识别是有缺陷的 修复详见: Use Vite tools to obtain environment variables #24 replace openai_api_base_url to api_base_url #25
  2. 如果你是Vercel部署,可以不使用.env文件,使用Vercel Project的环境变量即可。
  3. 注意API_BASE_URL指的是你反向代理Google PaLM API的地址,不是你自己搭建GeminiProChat的地址 反向代理的搭建:https://simonmy.com/posts/使用vercel反向代理google-palm-api.html

多谢

GODGOD126 avatar Dec 20 '23 10:12 GODGOD126

本地服务器上部署的,在启动服务器的时候,需要加上--https

pankejia2000 avatar Dec 25 '23 06:12 pankejia2000