[Request] 能否实现与 NextChat 相同的参数快捷填入功能? #3284
-
🥰 需求描述 | Feature Description是什么?NextChat( ChatGPT-Next-Web ) 原作者在其项目中,设置了一个参数快捷填入功能,但是好像并没有在Github中明说,只有用过原作者的中转站的人才会知道。 可以看出该功能可以直接快捷填入(只需要用户点个确定即可) base url 和 key 这两个最关键的参数。 要想实现这个效果,需要按照特定的格式设置访问链接,其格式为: 你们可以自己试试看。 为什么?
🧐 解决方案 | Proposed Solution很抱歉,具体解决方案我给不出来。 📝 补充信息 | Additional Information
|
Beta Was this translation helpful? Give feedback.
Replies: 27 comments
-
👀 @B3nDan Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible. |
Beta Was this translation helpful? Give feedback.
-
🥰 Requirement Description | Feature DescriptionWhat is it?The original author of NextChat ( ChatGPT-Next-Web ) set up a parameter quick filling function in his project, but it does not seem to be clearly stated in Github. Only people who have used the original author's transfer station will know. It can be seen that this function can be filled in directly and quickly (the user only needs to click OK). The two most critical parameters are base url and key. To achieve this effect, the access link needs to be set in a specific format. The format is: You can try it yourself. Why?
🧐 Solution | Proposed SolutionSorry, I can't give you a specific solution. 📝 Additional Information |
|
Beta Was this translation helpful? Give feedback.
-
感觉可以。我考虑下结合进来 |
Beta Was this translation helpful? Give feedback.
-
It feels OK. I'll consider combining it |
Beta Was this translation helpful? Give feedback.
-
对于这个问题,我也尝试做了实现,与NextChat不同,该实现不弹出模态框询问是否导入配置。不弹出模态框是因为多次遇到第一次使用NextChat的初学者时在导入配置的模态框中点了“取消”,导致配置导入失败。以下实现参数完全兼容NextChat。 https://github.com/cy948/lobe-chat/blob/5d40b61ad3e0eb739691235a47c163bd2ca174de/src/app/home/Redirect.tsx#L36 该实现大部分情况下能用,但小概率在用户第一次访问网站并导入时,因为App State初始化等问题会导致导入失败,此时重新访问配置URL即可解决问题。期待社区有更好的实现。 |
Beta Was this translation helpful? Give feedback.
-
Regarding this problem, I also tried to implement it. Unlike NextChat, this implementation does not pop up a modal box asking whether to import the configuration. The reason why the modal box does not pop up is because many times when beginners using NextChat for the first time clicked "Cancel" in the modal box of importing configuration, causing the configuration import to fail. The following implementation parameters are fully compatible with NextChat. https://github.com/cy948/lobe-chat/blob/5d40b61ad3e0eb739691235a47c163bd2ca174de/src/app/home/Redirect.tsx#L36 This implementation can be used in most cases, but there is a small chance that it will be imported when the user visits the website for the first time. Sometimes, the import may fail due to problems such as App State initialization. At this time, revisiting the configuration URL can solve the problem. Looking forward to better implementation from the community. |
Beta Was this translation helpful? Give feedback.
-
补充一个实现: 在 import { useSearchParams } from 'next/navigation';
const [setConfig] = useGlobalStore((s) => [
s.setModelProviderConfig,
]);
// feat: import settings from url
// example: https://example.com/?settings={"key":"sk-***"","url":"https://aiproxy.example.com/v1"}
const searchParams = useSearchParams();
const settings = searchParams.get('settings');
useEffect(() => {
// try to parse and set settings
if (settings) {
try {
const setting = JSON.parse(settings);
const { url, key } = setting as {
key?: string;
url?: string;
};
// set settings
if (key) setConfig('openAI', { OPENAI_API_KEY: key });
if (url) setConfig('openAI', { endpoint: url });
} catch {}
}
}, [settings]); 👍:相比于先前的实现,这个实现能够稳定导入配置 |
Beta Was this translation helpful? Give feedback.
-
能尝试提交一下pr吗,自己改的话完全跟不上lobechat的更新速度,一天几个版太快了 |
Beta Was this translation helpful? Give feedback.
-
上面提到的两种实现都有bug,不太能提PR,你可以在自己fork的版本上面进行修改。 |
Beta Was this translation helpful? Give feedback.
-
@YOMIkio @cy948 I have time to write an RFC recently. If you are interested, you can submit a PR based on my ideas. |
Beta Was this translation helpful? Give feedback.
-
好,到时候请在 RFC 中 at 我 🫡 |
Beta Was this translation helpful? Give feedback.
-
OK, please at me in the RFC then 🫡 |
Beta Was this translation helpful? Give feedback.
-
同求!这个功能结合 OneAPI 使用会非常方便! |
Beta Was this translation helpful? Give feedback.
-
Seeking the same! This function is very convenient to use in conjunction with OneAPI! |
Beta Was this translation helpful? Give feedback.
-
给一个我的版本 8b1137e {
openAI: {
OPENAI_API_KEY?: string;
endpoint?: string;
};
}; 根据需求,增加type定义即可。 @arvinxx 可以考虑confg传入定义,去设计RFC |
Beta Was this translation helpful? Give feedback.
-
give me my version
Just add the type definition according to your needs. |
Beta Was this translation helpful? Give feedback.
-
🤔 这样设计不就不兼容 OneApi 的URL传入参数了么。 |
Beta Was this translation helpful? Give feedback.
-
OneApi就没增减Lobe的链接,那边增加的时候加上相应参数即可在 2024年3月10日,上午12:59,cy948 ***@***.***> 写道:
给一个我的版本 8b1137e ***@***.*** 的版本通用,能传入所有的config,但同时只取合法的类型,比如
{
openAI: {
OPENAI_API_KEY?: string;
endpoint?: string;
};
};
根据需求,增加type定义即可。
@arvinxx 可以考虑confg传入定义,去设计RFC
🤔 这样设计不就不兼容 OneApi 的URL传入参数了么。
https://github.com/songquanpeng/one-api/blob/cf16f4497056ef6a2f2ddbe431863e3ccc57bfed/web/default/src/components/TokensTable.js#L99
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
除了url参数之外,更大的问题就是如何才能优雅地写入参数。issue里提过的两种方案都各存在问题,你有更好的方案吗?
|
Beta Was this translation helpful? Give feedback.
-
In addition to url parameters, the bigger problem is how to write parameters elegantly. Both solutions mentioned in the issue have their own problems. Do you have a better solution? |
Beta Was this translation helpful? Give feedback.
-
RFC: #1632 |
Beta Was this translation helpful? Give feedback.
-
✅ @bbb3n This issue is closed, If you have any questions, you can comment and reply. |
Beta Was this translation helpful? Give feedback.
-
🎉 This issue has been resolved in version 0.152.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Beta Was this translation helpful? Give feedback.
-
请问有没有可以快捷带入的例子 应该怎么拼接setting |
Beta Was this translation helpful? Give feedback.
-
Is there any example that can be quickly imported? How should setting be spliced? |
Beta Was this translation helpful? Give feedback.
-
@xuzeyu91 看文档,https://lobehub.com/docs/self-hosting/advanced/settings-url-share |
Beta Was this translation helpful? Give feedback.
@xuzeyu91 看文档,https://lobehub.com/docs/self-hosting/advanced/settings-url-share