Skip to content

Commit

Permalink
🚚 refactor: move the conversation and chatInput to features folder (l…
Browse files Browse the repository at this point in the history
…obehub#750)

* 🚚 refactor: move the conversation and chat input to features

* ⚑️ perf: dynamic import openapi plugin resolver to improve performance
  • Loading branch information
arvinxx authored Dec 22, 2023
1 parent 5100b65 commit 0334592
Show file tree
Hide file tree
Showing 82 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/app/chat/(desktop)/features/ChatInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { Maximize2, Minimize2 } from 'lucide-react';
import { memo, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';

import ActionBar from '@/app/chat/features/ChatInput/ActionBar';
import SaveTopic from '@/app/chat/features/ChatInput/Topic';
import { useChatInput } from '@/app/chat/features/ChatInput/useChatInput';
import {
CHAT_TEXTAREA_HEIGHT,
CHAT_TEXTAREA_MAX_HEIGHT,
HEADER_HEIGHT,
} from '@/const/layoutTokens';
import ActionBar from '@/features/ChatInput/ActionBar';
import SaveTopic from '@/features/ChatInput/Topic';
import { useChatInput } from '@/features/ChatInput/useChatInput';

import DragUpload from './DragUpload';
import { LocalFiles } from './LocalFiles';
Expand Down
2 changes: 1 addition & 1 deletion src/app/chat/(desktop)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { FC, memo } from 'react';
import { Flexbox } from 'react-layout-kit';

import ResponsiveIndex from '@/components/ResponsiveIndex';
import Conversation from '@/features/Conversation';

import Conversation from '../features/Conversation';
import PageTitle from '../features/PageTitle';
import ChatHeader from './features/ChatHeader';
import ChatInput from './features/ChatInput';
Expand Down
8 changes: 4 additions & 4 deletions src/app/chat/(mobile)/features/ChatInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { useTheme } from 'antd-style';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';

import ActionBar from '@/app/chat/features/ChatInput/ActionBar';
import STT from '@/app/chat/features/ChatInput/STT';
import SaveTopic from '@/app/chat/features/ChatInput/Topic';
import { useChatInput } from '@/app/chat/features/ChatInput/useChatInput';
import ActionBar from '@/features/ChatInput/ActionBar';
import STT from '@/features/ChatInput/STT';
import SaveTopic from '@/features/ChatInput/Topic';
import { useChatInput } from '@/features/ChatInput/useChatInput';

import Files from './Files';

Expand Down
2 changes: 1 addition & 1 deletion src/app/chat/(mobile)/mobile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import dynamic from 'next/dynamic';
import { memo } from 'react';
import { Flexbox } from 'react-layout-kit';

import Conversation from '@/features/Conversation';
import { useSessionStore } from '@/store/session';

import Conversation from '../../features/Conversation';
import ChatInput from '../features/ChatInput';
import Layout from './layout.mobile';

Expand Down
2 changes: 1 addition & 1 deletion src/app/chat/features/ChatHeader/ShareButton/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useTranslation } from 'react-i18next';
import { Flexbox } from 'react-layout-kit';

import pkg from '@/../package.json';
import ChatList from '@/app/chat/features/Conversation/ChatList';
import ChatList from '@/features/Conversation/ChatList';
import { useSessionStore } from '@/store/session';
import { agentSelectors, sessionSelectors } from '@/store/session/selectors';

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions src/services/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import {
LobeChatPluginsMarketIndex,
pluginManifestSchema,
} from '@lobehub/chat-plugin-sdk';
import { OpenAPIConvertor } from '@lobehub/chat-plugin-sdk/openapi';
import YAML from 'yaml';

import { getPluginIndexJSON } from '@/const/url';
import { PluginModel } from '@/database/models/plugin';
Expand Down Expand Up @@ -40,6 +38,8 @@ class PluginService {
if (contentType === 'application/json') {
data = await res.json();
} else {
const { default: YAML } = await import('yaml');

const yaml = await res.text();
data = YAML.parse(yaml);
}
Expand Down Expand Up @@ -94,6 +94,8 @@ class PluginService {
const openapiJson = await this._fetchJSON(parser.data.openapi, useProxy);

try {
const { OpenAPIConvertor } = await import('@lobehub/chat-plugin-sdk/openapi');

const convertor = new OpenAPIConvertor(openapiJson);
const openAPIs = await convertor.convertOpenAPIToPluginSchema();
data.api = [...data.api, ...openAPIs];
Expand Down

0 comments on commit 0334592

Please sign in to comment.