Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/lobehub/lobe-chat
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Dec 28, 2024
2 parents aa7075e + 079eaaa commit 94bbbc8
Show file tree
Hide file tree
Showing 24 changed files with 266 additions and 209 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,33 @@

# Changelog

## [Version 1.41.0](https://github.com/lobehub/lobe-chat/compare/v1.40.4...v1.41.0)

<sup>Released on **2024-12-28**</sup>

#### ✨ Features

- **auth**: Add WeChat authentication support.
- **misc**: Support white list for discover assistant.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's improved

- **auth**: Add WeChat authentication support, closes [#5195](https://github.com/lobehub/lobe-chat/issues/5195) ([95153a4](https://github.com/lobehub/lobe-chat/commit/95153a4))
- **misc**: Support white list for discover assistant, closes [#5216](https://github.com/lobehub/lobe-chat/issues/5216) ([90bb20d](https://github.com/lobehub/lobe-chat/commit/90bb20d))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>

### [Version 1.40.4](https://github.com/lobehub/lobe-chat/compare/v1.40.3...v1.40.4)

<sup>Released on **2024-12-28**</sup>
Expand Down
7 changes: 7 additions & 0 deletions changelog/v1.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
[
{
"children": {
"features": ["Support white list for discover assistant."]
},
"date": "2024-12-28",
"version": "1.41.0"
},
{
"children": {
"improvements": ["Update deepseek V3 model."]
Expand Down
46 changes: 46 additions & 0 deletions docs/self-hosting/advanced/auth/next-auth/wechat.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: Configure Wechat Authentication Service in LobeChat
description: Learn how to configure Wechat authentication service in LobeChat, including creating a new Wechat App, setting permissions, and environment variables.
tags:
- Wechat Authentication
- Wechat App
- Environment Variable Configuration
- Single Sign-On
- LobeChat
---

# Configure Wechat Authentication Service

## Wechat Configuration Process

<Steps>
### Create a Wechat Application

Click [here](https://open.weixin.qq.com/cgi-bin/index) and then click "Management Center", "Website Application", and "Create Website Application" in sequence.

Fill in the information as required by the official website prompts and submit for review.

After successful creation, click "Application Details" to obtain the AppID and AppSecret.

### Configure Environment Variables

When deploying LobeChat, you need to configure the following environment variables:

| Environment Variable | Type | Description |
| --- | --- | --- |
| `NEXT_AUTH_SECRET` | Required | Key used to encrypt Auth.js session tokens. You can generate the key using the command: `openssl rand -base64 32` |
| `NEXT_AUTH_SSO_PROVIDERS` | Required | Select the Single Sign-On provider for LobeChat. Use `github` for Github. |
| `WECHAT_CLIENT_ID` | Required | Client ID from the Wechat website application details page |
| `WECHAT_CLIENT_SECRET` | Required | Client Secret from the Wechat website application details page |
| `NEXTAUTH_URL` | Required | This URL is used to specify the callback address for Auth.js when performing OAuth authentication. Only set it if the default generated redirect address is incorrect. `https://example.com/api/auth` |

<Callout type={'tip'}>
Go to [📘 Environment Variables](/en/docs/self-hosting/environment-variables/auth#wechat) for more details about related variables.

</Callout>
</Steps>

<Callout type={'info'}>
After successful deployment, users will be able to authenticate through the WeChat Open Platform
and use LobeChat.
</Callout>
43 changes: 43 additions & 0 deletions docs/self-hosting/advanced/auth/next-auth/wechat.zh-CN.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: 在 LobeChat 中配置微信身份验证服务
description: 学习如何在 LobeChat 中配置微信身份验证服务,包括创建新的微信网站应用、设置权限和环境变量。
tags:
-微信身份验证
-微信网站应用
- 环境变量配置
- 单点登录
- LobeChat
---

# 配置微信身份验证服务

##微信配置流程

<Steps>
### 创建微信网站应用

点击 [这里](https://open.weixin.qq.com/cgi-bin/index) 依次点击“管理中心”、“网站应用”、“创建网站应用”

按照管网提示要求填写信息并提交审核。

创建成功后,点击“应用详情”,可获知AppID和AppSecret。

### 配置环境变量

在部署 LobeChat 时,你需要配置以下环境变量:

| 环境变量 | 类型 | 描述 |
| --- | --- | --- |
| `NEXT_AUTH_SECRET` | 必选 | 用于加密 Auth.js 会话令牌的密钥。您可以使用以下命令生成秘钥: `openssl rand -base64 32` |
| `NEXT_AUTH_SSO_PROVIDERS` | 必选 | 选择 LoboChat 的单点登录提供商。使用 Github 请填写 `github`|
| `WECHAT_CLIENT_ID` | 必选 |微信网站应用详情页的 客户端 ID |
| `WECHAT_CLIENT_SECRET` | 必选 |微信网站应用详情页的 客户端 Secret |
| `NEXTAUTH_URL` | 必选 | 该 URL 用于指定 Auth.js 在执行 OAuth 验证时的回调地址,当默认生成的重定向地址发生不正确时才需要设置。`https://example.com/api/auth` |

<Callout type={'tip'}>
前往 [📘 环境变量](/zh/docs/self-hosting/environment-variables/auth#wechat) 可查阅相关变量详情。

</Callout>
</Steps>

<Callout type={'info'}>部署成功后,用户将可以通过微信开放平台身份认证并使用 LobeChat。</Callout>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lobehub/chat",
"version": "1.40.4",
"version": "1.41.0",
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
"keywords": [
"framework",
Expand Down
13 changes: 2 additions & 11 deletions src/app/(backend)/webapi/assistant/store/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { NextResponse } from 'next/server';

import { DEFAULT_LANG } from '@/const/locale';
import { AssistantStore } from '@/server/modules/AssistantStore';

export const runtime = 'edge';
Expand All @@ -11,18 +10,10 @@ export const GET = async (req: Request) => {

const market = new AssistantStore();

let res: Response;
const data = await market.getAgentIndex(locale as any);

res = await fetch(market.getAgentIndexUrl(locale as any));

if (res.status === 404) {
res = await fetch(market.getAgentIndexUrl(DEFAULT_LANG));
}

const data = await res.json();
return NextResponse.json(data);
} catch (e) {
console.error(e);
} catch {
return new Response(`failed to fetch agent market index`, {
headers: {
'Access-Control-Allow-Origin': '*',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import { Button, Dropdown } from 'antd';
import { createStyles } from 'antd-style';
import { ChevronDownIcon, SquareArrowOutUpRight } from 'lucide-react';
import Link from 'next/link';
import { useRouter } from 'next/navigation';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { FlexboxProps } from 'react-layout-kit';

import { useOpenSettings } from '@/hooks/useInterceptingRoutes';
import { SettingsTabs } from '@/store/global/initialState';
import { DiscoverProviderItem } from '@/types/discover';

const useStyles = createStyles(({ css }) => ({
Expand All @@ -29,7 +28,11 @@ interface ProviderConfigProps extends FlexboxProps {
const ProviderConfig = memo<ProviderConfigProps>(({ data }) => {
const { styles } = useStyles();
const { t } = useTranslation('discover');
const openSettings = useOpenSettings(SettingsTabs.LLM);

const router = useRouter();
const openSettings = () => {
router.push('/settings/llm');
};

const icon = <Icon icon={SquareArrowOutUpRight} size={{ fontSize: 16 }} />;

Expand All @@ -56,7 +59,7 @@ const ProviderConfig = memo<ProviderConfigProps>(({ data }) => {

if (!items || items?.length === 0)
return (
<Button onClick={openSettings} size={'large'} style={{ flex: 1 }} type={'primary'}>
<Button size={'large'} style={{ flex: 1 }} type={'primary'}>
{t('providers.config')}
</Button>
);
Expand Down
45 changes: 0 additions & 45 deletions src/app/@modal/(.)settings/modal/index.tsx

This file was deleted.

47 changes: 0 additions & 47 deletions src/app/@modal/(.)settings/modal/layout.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions src/app/@modal/(.)settings/modal/loading.tsx

This file was deleted.

19 changes: 0 additions & 19 deletions src/app/@modal/(.)settings/modal/page.tsx

This file was deleted.

4 changes: 4 additions & 0 deletions src/config/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export const getAppConfig = () => {
PLUGIN_SETTINGS: z.string().optional(),

APP_URL: z.string().optional(),
VERCEL_EDGE_CONFIG: z.string().optional(),

CDN_USE_GLOBAL: z.boolean().optional(),
CUSTOM_FONT_FAMILY: z.string().optional(),
CUSTOM_FONT_URL: z.string().optional(),
Expand Down Expand Up @@ -75,6 +77,8 @@ export const getAppConfig = () => {

PLUGIN_SETTINGS: process.env.PLUGIN_SETTINGS,

VERCEL_EDGE_CONFIG: process.env.VERCEL_EDGE_CONFIG,

APP_URL,
CUSTOM_FONT_FAMILY: process.env.CUSTOM_FONT_FAMILY,
CUSTOM_FONT_URL: process.env.CUSTOM_FONT_URL,
Expand Down
5 changes: 3 additions & 2 deletions src/features/MobileTabBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { rgba } from 'polished';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';

import { useOpenSettings } from '@/hooks/useInterceptingRoutes';
import { SidebarTabKey } from '@/store/global/initialState';
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';

Expand All @@ -26,8 +25,10 @@ interface Props {
export default memo<Props>(({ className, tabBarKey }) => {
const { t } = useTranslation('common');
const { styles } = useStyles();
const openSettings = useOpenSettings();
const router = useRouter();
const openSettings = () => {
router.push('/settings/llm');
};
const { showMarket } = useServerConfigStore(featureFlagsSelectors);

const items: MobileTabBarProps['items'] = useMemo(
Expand Down
4 changes: 2 additions & 2 deletions src/features/User/UserAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ const UserAvatar = forwardRef<HTMLDivElement, UserAvatarProps>(

return (
<Avatar
alt={isSignedIn ? (username as string) : BRANDING_NAME}
avatar={isSignedIn ? avatar || DEFAULT_USER_AVATAR_URL : DEFAULT_USER_AVATAR_URL}
alt={isSignedIn && !!username ? username : BRANDING_NAME}
avatar={isSignedIn && !!avatar ? avatar : DEFAULT_USER_AVATAR_URL}
background={isSignedIn && avatar ? background : undefined}
className={cx(clickable && styles.clickable, className)}
ref={ref}
Expand Down
Loading

0 comments on commit 94bbbc8

Please sign in to comment.