lobe-chat icon indicating copy to clipboard operation
lobe-chat copied to clipboard

能否提供PROXY_URL 配置

Open zt199510 opened this issue 1 year ago • 33 comments

🥰 需求描述

当前的OPENAI_PROXY_URL 可能需要自己去部署一个代理服务,感觉有点多余 ,直接提供PROXY_URL会更方便一点

🧐 解决方案

直接提供PROXY_URL 配置

📝 补充信息

zt199510 avatar Jan 09 '24 02:01 zt199510

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


🥰 Description of requirements

The current OPENAI_PROXY_URL requires you to deploy a proxy service yourself, which feels a bit redundant. It would be more convenient to provide PROXY_URL directly.

🧐 Solution

Provide PROXY_URL configuration directly

📝 Supplementary information

None

lobehubbot avatar Jan 09 '24 02:01 lobehubbot

👀 @zt199510

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible. Please make sure you have given us as much context as possible.
非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。

lobehubbot avatar Jan 09 '24 02:01 lobehubbot

这个在设置里有啊Screenshot_2024-01-14-12-08-53-625_com.microsoft.emmx-edit.jpg

TonyBlur avatar Jan 14 '24 04:01 TonyBlur

这个在设置里有啊Screenshot_2024-01-14-12-08-53-625_com.microsoft.emmx-edit.jpg

这个需要你自己再去部署一个代理服务器 然后填写地址 直接使用Proxy_URL 就不需要

zt199510 avatar Jan 14 '24 08:01 zt199510

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


This is in the settings! [Screenshot_2024-01-14-12-08-53-625_com.microsoft.emmx-edit.jpg](https://private-user-images.githubusercontent.com/101348912/296529251- d884a89c-b568-45c3-80fb-f0c181bebee2.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb25 0ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDUyMTk2MTQsIm5iZiI6MTcwNTIxOTMxNCwicGF0aCI6Ii8xMDEzNDg5MTIvMjk2NTI5MjUxLWQ4ODRhODljLWI1NjgtNDVjMy04MGZiLWYwYzE4MWJ lYmVlMi5qcGc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwMTE0JTJGdXMtZWFzdC0xJTJGczMlMk Zhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDExNFQwODAxNTRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0xZTkyZTE4MDkwNjc2NTU4MGFkM2YwNmEzNDYzYjM4OGYzMm IwYzI3OWI0ZWQzMWQ2NTY3ZWIyMjVhYTQ5OGM5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.3ETB1ksBUFqTD62f-kqw2Nb572No77 ivzeQxUHWsTrI)

This requires you to deploy a proxy server yourself and fill in the address. It is not necessary to use Proxy_URL directly.

lobehubbot avatar Jan 14 '24 08:01 lobehubbot

这个在设置里有啊Screenshot_2024-01-14-12-08-53-625_com.microsoft.emmx-edit.jpg

这个需要你自己再去部署一个代理服务器 然后填写地址 直接使用Proxy_URL 就不需要

不用自己部署啊,你直接在这里输入代理API的地址和key就能用

TonyBlur avatar Jan 14 '24 08:01 TonyBlur

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


This is in the settings! [Screenshot_2024-01-14-12-08-53-625_com.microsoft.emmx-edit.jpg](https://private-user-images.githubusercontent.com/101348912/296529251 -d884a89c-b568-45c3-80fb-f0c181bebee2.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb25 0ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDUyMTk2MTQsIm5iZiI6MTcwNTIxOTMxNCwicGF0aCI6Ii8xMDEzNDg5MTIvMjk2NTI5MjUxLWQ4ODRhODljLWI1NjgtNDVjMy04MGZiLWYwYzE4MWJ lYmVlMi5qcGc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwMTE0JTJGdXMtZWFzdC0xJTJGczMlMk Zhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDExNFQwODAxNTRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0xZTkyZTE4MDkwNjc2NTU4MGFkM2YwNmEzNDYzYjM4OGYzMm IwYzI3OWI0ZWQzMWQ2NTY3ZWIyMjVhYTQ5OGM5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.3ETB1ksBUFqTD62f-kqw2Nb572No77 ivzeQxUHWsTrI)

This requires you to deploy a proxy server yourself and fill in the address. It is not necessary to use Proxy_URL directly.

You don’t need to deploy it yourself. You can directly enter the address and key of the proxy API here to use it.

lobehubbot avatar Jan 14 '24 08:01 lobehubbot

这个在设置里有啊Screenshot_2024-01-14-12-08-53-625_com.microsoft.emmx-edit.jpg

这个需要你自己再去部署一个代理服务器 然后填写地址 直接使用Proxy_URL 就不需要

不用自己部署啊,你直接在这里输入代理API的地址和key就能用

他要的是走本地代理,就是翻墙,比如 v2ray 的10809端口

piwawa avatar Feb 02 '24 13:02 piwawa

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


This is in the settings! [Screenshot_2024-01-14-12-08-53-625_com.microsoft.emmx-edit.jpg](https://private-user-images.githubusercontent.com/101348912/ 296529251-d884a89c-b568-45c3-80fb-f0c181bebee2.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1Y nVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDUyMTk2MTQsIm5iZiI6MTcwNTIxOTMxNCwicGF0aCI6Ii8xMDEzNDg5MTIvMjk2NTI5MjUxLWQ4ODRhODljLWI1NjgtNDVjMy04MGZi LWYwYzE4MWJlYmVlMi5qcGc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwMTE0JTJGdXMtZWFzdC0 xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDExNFQwODAxNTRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0xZTkyZTE4MDkwNjc2NTU4MGFkM2YwNmEzNDY zYjM4OGYzMmIwYzI3OWI0ZWQzMWQ2NTY3ZWIyMjVhYTQ5OGM5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.3ETB1ksBUFqTD62f-kq w2Nb572No77ivzeQxUHWsTrI)

This requires you to deploy a proxy server yourself and fill in the address. It is not necessary to use Proxy_URL directly.

You don’t need to deploy it yourself. You can directly enter the address and key of the proxy API here to use it.

What he wants is to use a local proxy, which is to bypass the wall, such as v2ray's 10809 port

lobehubbot avatar Feb 02 '24 13:02 lobehubbot

参见 https://github.com/lobehub/lobe-chat/issues/524

你可以使用上述问题中提到的 Vercel 透明代理来解决这个问题。

zhuozhiyongde avatar Feb 02 '24 14:02 zhuozhiyongde

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


See https://github.com/lobehub/lobe-chat/issues/524

You can solve this problem by using the Vercel transparent proxy mentioned in the above question.

lobehubbot avatar Feb 02 '24 14:02 lobehubbot

这次在做多 Provider 方案时,发现 proxy 是必须的 (Google Gemini 的 sdk 不支持 baseURL)

因此会支持上 HTTP_PROXY_URL 环境变量来提供本地代理:https://github.com/lobehub/lobe-chat/pull/1173

arvinxx avatar Feb 02 '24 14:02 arvinxx

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


This time when doing a multi-provider solution, I found that proxy is necessary.

Therefore, the HTTP_PROXY_URL environment variable will be supported to provide a local proxy.

lobehubbot avatar Feb 02 '24 14:02 lobehubbot

这次在做多 Provider 方案时,发现 proxy 是必须的。

因此会支持上 HTTP_PROXY_URL 环境变量来提供本地代理:#1173

好耶

zhuozhiyongde avatar Feb 02 '24 15:02 zhuozhiyongde

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


This time when doing a multi-provider solution, I found that proxy is necessary.

Therefore, the HTTP_PROXY_URL environment variable will be supported to provide a local proxy: #1173

Great

lobehubbot avatar Feb 02 '24 15:02 lobehubbot

这次在做多 Provider 方案时,发现 proxy 是必须的 (Google Gemini 的 sdk 不支持 baseURL)

因此会支持上 HTTP_PROXY_URL 环境变量来提供本地代理:#1173

请问下在哪个版本会支持这个环境变量啊?

shorexilin avatar Feb 21 '24 01:02 shorexilin

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


This time when doing a multi-provider solution, I found that proxy is necessary (Google Gemini’s sdk does not support baseURL)

Therefore, the HTTP_PROXY_URL environment variable will be supported to provide a local proxy: #1173

May I ask which version supports this environment variable?

lobehubbot avatar Feb 21 '24 01:02 lobehubbot

HTTP_PROXY_URL

@arvinxx 大佬,请问这个能力啥时候可以上啊

coulsontl avatar Feb 23 '24 12:02 coulsontl

这次在做多 Provider 方案时,发现 proxy 是必须的 (Google Gemini 的 sdk 不支持 baseURL)

因此会支持上 HTTP_PROXY_URL 环境变量来提供本地代理:#1173

这个 env 是不是现在还没加上?

piwawa avatar Mar 05 '24 05:03 piwawa

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


This time when doing a multi-provider solution, I found that proxy is necessary (Google Gemini’s sdk does not support baseURL)

Therefore, the HTTP_PROXY_URL environment variable will be supported to provide a local proxy: #1173

Is this env not added yet?

lobehubbot avatar Mar 05 '24 05:03 lobehubbot

@piwawa 对,功能其实实现了,但是没实装: https://github.com/lobehub/lobe-chat/blob/main/src/app/api/chat/google/route.ts#L3-L14

原因是这个配置只能在 Node 环境下跑,一旦开启以后就没法切到 Edge Runtime 了,这会导致vercel 部署的体验受到很大的影响。 cc @coulsontl @shorexilin @zhuozhiyongde

arvinxx avatar Mar 05 '24 06:03 arvinxx

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@piwawa Yes, the function is actually implemented, but it is not installed: https://github.com/lobehub/lobe-chat/blob/main/src/app/api/chat/google/route.ts#L3-L14

The reason is that this configuration can only be run in the Node environment. Once it is turned on, it cannot be switched to Edge Runtime, which will greatly affect the vercel deployment experience.

lobehubbot avatar Mar 05 '24 06:03 lobehubbot

@piwawa 对,功能其实实现了,但是没实装: https://github.com/lobehub/lobe-chat/blob/main/src/app/api/chat/google/route.ts#L3-L14

原因是这个配置只能在 Node 环境下跑,一旦开启以后就没法切到 Edge Runtime 了,这会导致vercel 部署的体验受到很大的影响。 cc @coulsontl @shorexilin @zhuozhiyongde

更新之后一直没法调用api,我这个api是oneapi部署的,用chatgpt-next-web和本地调用 (不翻墙) 都没问题,就这个lobe不行,加 /v1 和不加都报错,能看下问题原因吗?

image image

 ⨯ Error: fetch failed
    at context.fetch (/app/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/web/sandbox/context.js:272:38)
    at r (/app/.next/server/edge-chunks/699.js:5589:76)
    at doOriginalFetch (/app/.next/server/edge-chunks/699.js:8034:24)
    at /app/.next/server/edge-chunks/699.js:8159:20
    at /app/.next/server/edge-chunks/699.js:8409:36
    at NoopContextManager.with (/app/.next/server/edge-chunks/699.js:732:30)
    at ContextAPI.with (/app/.next/server/edge-chunks/699.js:402:58)
    at NoopTracer.startActiveSpan (/app/.next/server/edge-chunks/699.js:1325:34)
    at ProxyTracer.startActiveSpan (/app/.next/server/edge-chunks/699.js:1365:36)
    at /app/.next/server/edge-chunks/699.js:8398:103 {
  cause: ConnectTimeoutError: Connect Timeout Error
      at onConnectTimeout (eval at requireWithFakeGlobalScope (/app/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/compiled/edge-runtime/index.js:1:657096), <anonymous>:9145:28)
      at eval (eval at requireWithFakeGlobalScope (/app/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/compiled/edge-runtime/index.js:1:657096), <anonymous>:9101:50)
      at Immediate.eval [as _onImmediate] (eval at requireWithFakeGlobalScope (/app/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/compiled/edge-runtime/index.js:1:657096), <anonymous>:9133:13)
      at process.processImmediate (node:internal/timers:478:21)
      at process.callbackTrampoline (node:internal/async_hooks:130:17) {
    code: 'UND_ERR_CONNECT_TIMEOUT'
  }
}
 ⨯ Error: fetch failed
    at context.fetch (/app/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/web/sandbox/context.js:272:38)
    at r (/app/.next/server/edge-chunks/699.js:5589:76)
    at doOriginalFetch (/app/.next/server/edge-chunks/699.js:8034:24)
    at /app/.next/server/edge-chunks/699.js:8159:20
    at /app/.next/server/edge-chunks/699.js:8409:36
    at NoopContextManager.with (/app/.next/server/edge-chunks/699.js:732:30)
    at ContextAPI.with (/app/.next/server/edge-chunks/699.js:402:58)
    at NoopTracer.startActiveSpan (/app/.next/server/edge-chunks/699.js:1325:34)
    at ProxyTracer.startActiveSpan (/app/.next/server/edge-chunks/699.js:1365:36)
    at /app/.next/server/edge-chunks/699.js:8398:103 {
  cause: ConnectTimeoutError: Connect Timeout Error
      at onConnectTimeout (eval at requireWithFakeGlobalScope (/app/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/compiled/edge-runtime/index.js:1:657096), <anonymous>:9145:28)
      at eval (eval at requireWithFakeGlobalScope (/app/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/compiled/edge-runtime/index.js:1:657096), <anonymous>:9101:50)
      at Immediate.eval [as _onImmediate] (eval at requireWithFakeGlobalScope (/app/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/compiled/edge-runtime/index.js:1:657096), <anonymous>:9133:13)
      at process.processImmediate (node:internal/timers:478:21)
      at process.callbackTrampoline (node:internal/async_hooks:130:17) {
    code: 'UND_ERR_CONNECT_TIMEOUT'
  }
}

piwawa avatar Mar 05 '24 06:03 piwawa

@piwawa 你 Discord 上私戳我帮你看看

arvinxx avatar Mar 05 '24 06:03 arvinxx

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@piwawa PM me privately on Discord and let me check it out for you

lobehubbot avatar Mar 05 '24 06:03 lobehubbot

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


HTTP_PROXY_URL

@arvinxx Boss, when will this ability be available?

@arvinxx Can you decide whether to open this code based on the channel when packaging?

lobehubbot avatar Mar 05 '24 11:03 lobehubbot

@piwawa 对,功能其实实现了,但是没实装: https://github.com/lobehub/lobe-chat/blob/main/src/app/api/chat/google/route.ts#L3-L14

原因是这个配置只能在 Node 环境下跑,一旦开启以后就没法切到 Edge Runtime 了,这会导致vercel 部署的体验受到很大的影响。 cc @coulsontl @shorexilin @zhuozhiyongde

@arvinxx 能否在打包的时候,根据渠道来决定是不是要打开这段代码?

coulsontl avatar Mar 05 '24 11:03 coulsontl

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@piwawa Yes, the function is actually implemented, but it is not installed: https://github.com/lobehub/lobe-chat/blob/main/src/app/api/chat/google/route.ts#L3-L14

The reason is that this configuration can only be run in the Node environment. Once enabled, you cannot switch to Edge Runtime, which will greatly affect the vercel deployment experience. cc @coulsontl @shorexilin @zhuozhiyongde

@arvinxx Can you decide whether to open this code based on the channel when packaging?

lobehubbot avatar Mar 05 '24 11:03 lobehubbot

既然lobe-chat是个纯前端应用,那是不是不管什么部署方式,只要浏览器翻出去了就行,而这只需要打开系统代理即可

CXwudi avatar Mar 06 '24 06:03 CXwudi

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Since lobe-chat is a pure front-end application, no matter what the deployment method is, as long as the browser is opened, it only needs to open the system proxy.

lobehubbot avatar Mar 06 '24 06:03 lobehubbot