Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from lobehub:main #160

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

# Changelog

### [Version 1.47.15](https://github.com/lobehub/lobe-chat/compare/v1.47.14...v1.47.15)

<sup>Released on **2025-01-22**</sup>

#### 💄 Styles

- **misc**: Improve discover model page.

<br/>

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

#### Styles

- **misc**: Improve discover model page, closes [#5544](https://github.com/lobehub/lobe-chat/issues/5544) ([979849c](https://github.com/lobehub/lobe-chat/commit/979849c))

</details>

<div align="right">

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

</div>

### [Version 1.47.14](https://github.com/lobehub/lobe-chat/compare/v1.47.13...v1.47.14)

<sup>Released on **2025-01-22**</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": {
"improvements": ["Improve discover model page."]
},
"date": "2025-01-22",
"version": "1.47.15"
},
{
"children": {
"improvements": ["Support model list with model fetcher settings."]
Expand Down
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.47.14",
"version": "1.47.15",
"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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { ModelIcon } from '@lobehub/icons';
import { Button } from 'antd';
import { createStyles } from 'antd-style';
import dayjs from 'dayjs';
import Link from 'next/link';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
Expand All @@ -20,7 +21,9 @@ export const useStyles = createStyles(({ css, token }) => ({
background: ${token.colorFillSecondary};
`,
time: css`
display: flex;
font-size: 12px;
line-height: 22px;
color: ${token.colorTextDescription};
`,
title: css`
Expand All @@ -41,6 +44,7 @@ const Header = memo<HeaderProps>(({ identifier, data, mobile }) => {
const { styles, theme } = useStyles();
const { t } = useTranslation(['discover', 'models']);

const releasedAt = data.meta.releasedAt;
return (
<Flexbox gap={12} width={'100%'}>
{!mobile && <Back href={'/discover/models'} />}
Expand All @@ -56,9 +60,11 @@ const Header = memo<HeaderProps>(({ identifier, data, mobile }) => {
style={{ color: theme.colorTextSecondary }}
>
<div>{identifier}</div>
<time className={styles.time} dateTime={new Date(data.createdAt).toISOString()}>
{data.createdAt}
</time>
{releasedAt && (
<time className={styles.time} dateTime={dayjs(releasedAt).toISOString()}>
{releasedAt}
</time>
)}
</Flexbox>
</Flexbox>
</Flexbox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ export interface SuggestionItemProps
extends Omit<DiscoverModelItem, 'suggestions' | 'socialData' | 'providers'>,
FlexboxProps {}

const SuggestionItem = memo<SuggestionItemProps>(({ className, meta, identifier, ...rest }) => {
const SuggestionItem = memo<SuggestionItemProps>(({ className, meta, identifier }) => {
const { title, description, contextWindowTokens, vision, functionCall } = meta;
const { t } = useTranslation('models');
const { cx, styles } = useStyles();

return (
<Flexbox className={cx(styles.container, className)} gap={12} key={identifier} {...rest}>
<Flexbox className={cx(styles.container, className)} gap={12} key={identifier}>
<Flexbox align={'center'} gap={12} horizontal width={'100%'}>
<ModelIcon model={identifier} size={36} type={'avatar'} />
<Flexbox style={{ overflow: 'hidden' }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ const ParameterList = memo<ParameterListProps>(({ data }) => {
<Block title={t('models.parameterList.title')}>
<Collapse
defaultActiveKey={items.map((item) => item.key)}
expandIconPosition={'right'}
expandIconPosition={'end'}
gap={16}
items={items.map((item) => ({
children: <ParameterItem {...item} />,
children: <ParameterItem {...item} key={item.key} />,
key: item.key,
label: (
<Flexbox align={'center'} gap={8} horizontal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ModelIcon } from '@lobehub/icons';
import { Divider } from 'antd';
import { useTheme } from 'antd-style';
import { BrainCircuit } from 'lucide-react';
import { memo } from 'react';
import { Fragment, memo } from 'react';
import { useTranslation } from 'react-i18next';

import { DiscoverProviderItem } from '@/types/discover';
Expand Down Expand Up @@ -33,10 +33,10 @@ const ProviderList = memo<ProviderListProps>(({ mobile, data, identifier }) => {
title={t('models.supportedProviders')}
>
{data.map((item, index) => (
<>
<ProviderItem key={item.identifier} mobile={mobile} modelId={identifier} {...item} />
{index < data.length - 1 && <Divider key={index} style={{ margin: 0 }} />}
</>
<Fragment key={item.identifier}>
<ProviderItem mobile={mobile} modelId={identifier} {...item} />
{index < data.length - 1 && <Divider style={{ margin: 0 }} />}
</Fragment>
))}
</HighlightBlock>
);
Expand Down
13 changes: 2 additions & 11 deletions src/features/DevPanel/PostgresViewer/DataTable/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ import { createStyles } from 'antd-style';
import React from 'react';
import { Center } from 'react-layout-kit';
import { TableVirtuoso } from 'react-virtuoso';
import useSWR from 'swr';

import { tableViewerService } from '@/services/tableViewer';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';

import { useTableColumns } from '../useTableColumns';
import { usePgTable, useTableColumns } from '../usePgTable';
import TableCell from './TableCell';

const useStyles = createStyles(({ token, css }) => ({
Expand Down Expand Up @@ -100,12 +95,8 @@ const Table = ({ tableName }: TableProps) => {
const { styles } = useStyles();

const tableColumns = useTableColumns(tableName);
const isDBInited = useGlobalStore(systemStatusSelectors.isDBInited);

const tableData = useSWR(
isDBInited && tableName ? ['fetch-table-data', tableName] : null,
([, table]) => tableViewerService.getTableData(table),
);
const tableData = usePgTable(tableName);

const columns = tableColumns.data?.map((t) => t.name) || [];
const isLoading = tableColumns.isLoading || tableData.isLoading;
Expand Down
10 changes: 9 additions & 1 deletion src/features/DevPanel/PostgresViewer/DataTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { Button } from 'antd';
import { createStyles } from 'antd-style';
import { Download, Filter, RefreshCw } from 'lucide-react';
import React from 'react';
import { mutate } from 'swr';

import { FETCH_TABLE_DATA_KEY } from '../usePgTable';
import Table from './Table';

const useStyles = createStyles(({ token, css }) => ({
Expand Down Expand Up @@ -54,7 +56,13 @@ const DataTable = ({ tableName }: DataTableProps) => {
Filter
</Button>
<ActionIcon icon={Download} title={'Export'} />
<ActionIcon icon={RefreshCw} title={'Refresh'} />
<ActionIcon
icon={RefreshCw}
onClick={async () => {
await mutate(FETCH_TABLE_DATA_KEY(tableName));
}}
title={'Refresh'}
/>
</div>
</div>

Expand Down
13 changes: 2 additions & 11 deletions src/features/DevPanel/PostgresViewer/Schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@ import { createStyles } from 'antd-style';
import { ChevronDown, ChevronRight, Database, Table as TableIcon } from 'lucide-react';
import React, { useState } from 'react';
import { Flexbox } from 'react-layout-kit';
import useSWR from 'swr';

import { tableViewerService } from '@/services/tableViewer';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';

import TableColumns from './TableColumns';
import { useFetchTables } from './usePgTable';

// 样式定义
const useStyles = createStyles(({ token, css }) => ({
button: css`
cursor: pointer;
Expand Down Expand Up @@ -138,11 +133,7 @@ const SchemaPanel = ({ onTableSelect, selectedTable }: SchemaPanelProps) => {
const { styles, cx } = useStyles();
const [expandedTables, setExpandedTables] = useState(new Set());

const isDBInited = useGlobalStore(systemStatusSelectors.isDBInited);

const { data, isLoading } = useSWR(isDBInited ? 'fetch-tables' : null, () =>
tableViewerService.getAllTables(),
);
const { data, isLoading } = useFetchTables();

const toggleTable = (tableName: string) => {
const newExpanded = new Set(expandedTables);
Expand Down
2 changes: 1 addition & 1 deletion src/features/DevPanel/PostgresViewer/TableColumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createStyles } from 'antd-style';
import React from 'react';
import { Flexbox } from 'react-layout-kit';

import { useTableColumns } from './useTableColumns';
import { useTableColumns } from './usePgTable';

const useStyles = createStyles(({ token, css }) => ({
container: css`
Expand Down
31 changes: 31 additions & 0 deletions src/features/DevPanel/PostgresViewer/usePgTable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import useSWR from 'swr';

import { tableViewerService } from '@/services/tableViewer';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';

const FETCH_TABLES = 'fetch-tables';
const FETCH_TABLE_COLUMN_KEY = (tableName: string) => ['fetch-table-columns', tableName];
export const FETCH_TABLE_DATA_KEY = (tableName: string) => ['fetch-table-data', tableName];

export const useFetchTables = () => {
const isDBInited = useGlobalStore(systemStatusSelectors.isDBInited);

return useSWR(isDBInited ? FETCH_TABLES : null, () => tableViewerService.getAllTables());
};

export const useTableColumns = (tableName?: string) => {
const isDBInited = useGlobalStore(systemStatusSelectors.isDBInited);

return useSWR(isDBInited && tableName ? FETCH_TABLE_COLUMN_KEY(tableName) : null, ([, table]) =>
tableViewerService.getTableDetails(table),
);
};

export const usePgTable = (tableName?: string) => {
const isDBInited = useGlobalStore(systemStatusSelectors.isDBInited);

return useSWR(isDBInited && tableName ? FETCH_TABLE_DATA_KEY(tableName) : null, ([, table]) =>
tableViewerService.getTableData(table),
);
};
13 changes: 0 additions & 13 deletions src/features/DevPanel/PostgresViewer/useTableColumns.ts

This file was deleted.

3 changes: 3 additions & 0 deletions src/services/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export interface ImportResults {
type?: string;
}

/**
* @deprecated
*/
class ConfigService {
importConfigState = async (config: ConfigFile, callbacks?: OnImportCallbacks): Promise<void> => {
if (config.exportType === 'settings') {
Expand Down
Loading