Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ziyanwould committed Oct 7, 2024
2 parents c8c9208 + 8a0e45c commit f66decf
Show file tree
Hide file tree
Showing 76 changed files with 176 additions and 66 deletions.
58 changes: 58 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,64 @@

# Changelog

### [Version 1.21.6](https://github.com/lobehub/lobe-chat/compare/v1.21.5...v1.21.6)

<sup>Released on **2024-10-05**</sup>

#### ♻ Code Refactoring

- **misc**: Move backend api to (backend) folder group.

#### 🐛 Bug Fixes

- **misc**: Fix txt-to-image api.

<br/>

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

#### Code refactoring

- **misc**: Move backend api to (backend) folder group, closes [#4262](https://github.com/lobehub/lobe-chat/issues/4262) ([d8afb46](https://github.com/lobehub/lobe-chat/commit/d8afb46))

#### What's fixed

- **misc**: Fix txt-to-image api, closes [#4264](https://github.com/lobehub/lobe-chat/issues/4264) ([d1ff4ba](https://github.com/lobehub/lobe-chat/commit/d1ff4ba))

</details>

<div align="right">

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

</div>

### [Version 1.21.5](https://github.com/lobehub/lobe-chat/compare/v1.21.4...v1.21.5)

<sup>Released on **2024-10-05**</sup>

#### 💄 Styles

- **misc**: Support shadcn in Artifacts.

<br/>

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

#### Styles

- **misc**: Support shadcn in Artifacts, closes [#4256](https://github.com/lobehub/lobe-chat/issues/4256) ([863bae5](https://github.com/lobehub/lobe-chat/commit/863bae5))

</details>

<div align="right">

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

</div>

### [Version 1.21.4](https://github.com/lobehub/lobe-chat/compare/v1.21.3...v1.21.4)

<sup>Released on **2024-10-02**</sup>
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,12 @@ Our marketplace is not just a showcase platform but also a collaborative space.

| Recent Submits | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [A More Diligent Assistant](https://chat-preview.lobehub.com/market?agent=web-development)<br/><sup>By **[fasdfsdf-alt](https://github.com/fasdfsdf-alt)** on **2024-10-02**</sup> | A More Diligent Assistant<br/>`learning` |
| [C++/Qt](https://chat-preview.lobehub.com/market?agent=qt-c)<br/><sup>By **[liangyuR](https://github.com/liangyuR)** on **2024-09-30**</sup> | Excels in teaching C++/Qt coding practices<br/>`c` `qt` |
| [Birthday Invitation Messages](https://chat-preview.lobehub.com/market?agent=birthday-invitation-message)<br/><sup>By **[tcmonster](https://github.com/tcmonster)** on **2024-09-29**</sup> | Specializes in crafting engaging and personalized Birthday Invitation messages, catering to various themes and tones.<br/>`message-composition` `personalization` `tone-versatility` `event-detail-integration` `interaction-approach` |
| [Death Anniversary Messages](https://chat-preview.lobehub.com/market?agent=death-anniversary-message)<br/><sup>By **[tcmonster](https://github.com/tcmonster)** on **2024-09-29**</sup> | Specializes in crafting sensitive and heartfelt Death Anniversary messages with compassion and empathy.<br/>`condolences` `message-composition` `grief-support` `cultural-awareness` `emotional-sensitivity` |
| [Flux Prompt Generator](https://chat-preview.lobehub.com/market?agent=flux-prompt-generator)<br/><sup>By **[tcmonster](https://github.com/tcmonster)** on **2024-09-29**</sup> | Flux Prompt Generation Assistant: Expert in crafting detailed, creative prompts for high-quality image outputs from the Flux model.<br/>`prompt-generation` `image-generation` `art-style` `creativity` `crafting` |

> 📊 Total agents: [<kbd>**404**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
> 📊 Total agents: [<kbd>**405**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
<!-- AGENT LIST -->

Expand Down
16 changes: 8 additions & 8 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,14 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
<!-- AGENT LIST -->

| 最近新增 | 助手说明 |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| [C++/Qt](https://chat-preview.lobehub.com/market?agent=qt-c)<br/><sup>By **[liangyuR](https://github.com/liangyuR)** on **2024-09-30**</sup> | 擅长教授 C++/Qt 编程实践<br/>`c` `qt` |
| [生日邀请信息](https://chat-preview.lobehub.com/market?agent=birthday-invitation-message)<br/><sup>By **[tcmonster](https://github.com/tcmonster)** on **2024-09-29**</sup> | 专注于制作引人入胜和个性化的生日邀请信息,适应各种主题和语气。<br/>`信息构成` `个性化` `语气多样性` `活动细节整合` `互动方式` |
| [忌日信息](https://chat-preview.lobehub.com/market?agent=death-anniversary-message)<br/><sup>By **[tcmonster](https://github.com/tcmonster)** on **2024-09-29**</sup> | 专注于以同情和共情的方式撰写敏感且发自内心的忌日信息。<br/>`慰问` `信息撰写` `悲伤支持` `文化意识` `情感敏感性` |
| [Flux 提示生成器](https://chat-preview.lobehub.com/market?agent=flux-prompt-generator)<br/><sup>By **[tcmonster](https://github.com/tcmonster)** on **2024-09-29**</sup> | Flux 提示生成助手:专注于为 Flux 模型生成高质量图像输出而创作详细、创意提示的专家。<br/>`提示生成` `图像生成` `艺术风格` `创意` `创作` |

> 📊 Total agents: [<kbd>**404**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
| 最近新增 | 助手说明 |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| [更勤奋的助手](https://chat-preview.lobehub.com/market?agent=web-development)<br/><sup>By **[fasdfsdf-alt](https://github.com/fasdfsdf-alt)** on **2024-10-02**</sup> | 更勤奋的助手<br/>`学习` |
| [C++/Qt](https://chat-preview.lobehub.com/market?agent=qt-c)<br/><sup>By **[liangyuR](https://github.com/liangyuR)** on **2024-09-30**</sup> | 擅长教授 C++/Qt 编程实践<br/>`c` `qt` |
| [生日邀请信息](https://chat-preview.lobehub.com/market?agent=birthday-invitation-message)<br/><sup>By **[tcmonster](https://github.com/tcmonster)** on **2024-09-29**</sup> | 专注于制作引人入胜和个性化的生日邀请信息,适应各种主题和语气。<br/>`信息构成` `个性化` `语气多样性` `活动细节整合` `互动方式` |
| [忌日信息](https://chat-preview.lobehub.com/market?agent=death-anniversary-message)<br/><sup>By **[tcmonster](https://github.com/tcmonster)** on **2024-09-29**</sup> | 专注于以同情和共情的方式撰写敏感且发自内心的忌日信息。<br/>`慰问` `信息撰写` `悲伤支持` `文化意识` `情感敏感性` |

> 📊 Total agents: [<kbd>**405**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
<!-- AGENT LIST -->

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lobehub/chat",
"version": "1.21.4",
"version": "1.21.6",
"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 Expand Up @@ -300,7 +300,7 @@
"vitest": "~1.2.2",
"vitest-canvas-mock": "^0.3.3"
},
"packageManager": "pnpm@9.11.0",
"packageManager": "pnpm@9.12.0",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { getAuth } from '@clerk/nextjs/server';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';

import { checkAuthMethod, getJWTPayload } from '@/app/api/middleware/auth/utils';
import { checkAuthMethod, getJWTPayload } from '@/app/(backend)/api/middleware/auth/utils';
import { LOBE_CHAT_AUTH_HEADER, OAUTH_AUTHORIZED } from '@/const/auth';
import { AgentRuntime, LobeRuntimeAI } from '@/libs/agent-runtime';
import { ChatErrorType } from '@/types/fetch';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createErrorResponse } from '@/app/api/errorResponse';
import { createErrorResponse } from '@/app/(backend)/api/errorResponse';
import { AgentRuntime, ChatCompletionErrorPayload } from '@/libs/agent-runtime';
import { ChatErrorType } from '@/types/fetch';
import { ChatStreamPayload } from '@/types/openai/chat';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NextResponse } from 'next/server';

import { createErrorResponse } from '@/app/api/errorResponse';
import { createErrorResponse } from '@/app/(backend)/api/errorResponse';
import { ChatCompletionErrorPayload, ModelProvider } from '@/libs/agent-runtime';
import { ChatErrorType } from '@/types/fetch';

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getAuth } from '@clerk/nextjs/server';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';

import { createErrorResponse } from '@/app/api/errorResponse';
import { createErrorResponse } from '@/app/(backend)/api/errorResponse';
import { AgentRuntimeError } from '@/libs/agent-runtime';
import { ChatErrorType } from '@/types/fetch';

Expand All @@ -12,7 +12,7 @@ vi.mock('@clerk/nextjs/server', () => ({
getAuth: vi.fn(),
}));

vi.mock('@/app/api/errorResponse', () => ({
vi.mock('@/app/(backend)/api/errorResponse', () => ({
createErrorResponse: vi.fn(),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AuthObject } from '@clerk/backend';
import { getAuth } from '@clerk/nextjs/server';
import { NextRequest } from 'next/server';

import { createErrorResponse } from '@/app/api/errorResponse';
import { createErrorResponse } from '@/app/(backend)/api/errorResponse';
import { JWTPayload, LOBE_CHAT_AUTH_HEADER, OAUTH_AUTHORIZED, enableClerk } from '@/const/auth';
import { AgentRuntime, AgentRuntimeError, ChatCompletionErrorPayload } from '@/libs/agent-runtime';
import { ChatErrorType } from '@/types/fetch';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { PluginRequestPayload } from '@lobehub/chat-plugin-sdk';
import { createGatewayOnEdgeRuntime } from '@lobehub/chat-plugins-gateway';

import { createErrorResponse } from '@/app/api/errorResponse';
import { getJWTPayload } from '@/app/api/middleware/auth/utils';
import { createErrorResponse } from '@/app/(backend)/api/errorResponse';
import { getJWTPayload } from '@/app/(backend)/api/middleware/auth/utils';
import { getAppConfig } from '@/config/app';
import { LOBE_CHAT_AUTH_HEADER, OAUTH_AUTHORIZED, enableNextAuth } from '@/const/auth';
import { LOBE_CHAT_TRACE_ID, TraceNameMap } from '@/const/trace';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { OpenAISTTPayload } from '@lobehub/tts';
import { createOpenaiAudioTranscriptions } from '@lobehub/tts/server';

import { createBizOpenAI } from '@/app/api/openai/createBizOpenAI';
import { createBizOpenAI } from '@/app/(backend)/api/openai/createBizOpenAI';

export const runtime = 'edge';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NextResponse } from 'next/server';

import { initAgentRuntimeWithUserPayload } from '@/app/api/chat/agentRuntime';
import { createErrorResponse } from '@/app/api/errorResponse';
import { checkAuth } from '@/app/api/middleware/auth';
import { initAgentRuntimeWithUserPayload } from '@/app/(backend)/api/chat/agentRuntime';
import { createErrorResponse } from '@/app/(backend)/api/errorResponse';
import { checkAuth } from '@/app/(backend)/api/middleware/auth';
import { ChatCompletionErrorPayload } from '@/libs/agent-runtime';
import { TextToImagePayload } from '@/libs/agent-runtime/types';
import { ChatErrorType } from '@/types/fetch';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { OpenAITTSPayload } from '@lobehub/tts';
import { createOpenaiAudioSpeech } from '@lobehub/tts/server';

import { createBizOpenAI } from '@/app/api/openai/createBizOpenAI';
import { createBizOpenAI } from '@/app/(backend)/api/openai/createBizOpenAI';

export const runtime = 'edge';

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { SandpackLayout, SandpackPreview, SandpackProvider } from '@codesandbox/sandpack-react';
import { memo } from 'react';

import { useChatStore } from '@/store/chat';
import { chatPortalSelectors } from '@/store/chat/selectors';

import { createTemplateFiles } from './template';

interface ReactRendererProps {
code: string;
}

const ReactRenderer = memo<ReactRendererProps>(({ code }) => {
const title = useChatStore(chatPortalSelectors.artifactTitle);

return (
<SandpackProvider
customSetup={{
dependencies: {
'@lshay/ui': 'latest',
'@radix-ui/react-alert-dialog': 'latest',
'@radix-ui/react-dialog': 'latest',
'@radix-ui/react-icons': 'latest',
'antd': 'latest',
'class-variance-authority': 'latest',
'clsx': 'latest',
'lucide-react': 'latest',
'recharts': 'latest',
'tailwind-merge': 'latest',
},
}}
files={{
'App.tsx': code,
...createTemplateFiles({ title }),
}}
options={{
externalResources: ['https://cdn.tailwindcss.com'],
visibleFiles: ['App.tsx'],
}}
style={{ height: '100%' }}
template="vite-react-ts"
theme="auto"
>
<SandpackLayout style={{ height: '100%' }}>
<SandpackPreview style={{ height: '100%' }} />
</SandpackLayout>
</SandpackProvider>
);
});

export default ReactRenderer;
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
interface TemplateFilesParams {
title?: string;
}
export const createTemplateFiles = ({ title }: TemplateFilesParams = {}) => ({
'index.html': `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>${title || 'Artifacts App'}</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<div id="root"></div>
<script type="module" src="/index.tsx"></script>
</body>
</html>
`,
'vite.config.ts': {
code: `import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'@/components/ui': '@lshay/ui/components/default',
},
},
});`,
},
});
2 changes: 1 addition & 1 deletion src/libs/agent-runtime/AgentRuntime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { LangfuseGenerationClient, LangfuseTraceClient } from 'langfuse-core';
import { ClientOptions } from 'openai';
import { beforeEach, describe, expect, it, vi } from 'vitest';

import { createTraceOptions } from '@/app/api/chat/agentRuntime';
import { createTraceOptions } from '@/app/(backend)/api/chat/agentRuntime';
import * as langfuseCfg from '@/config/langfuse';
import { JWTPayload } from '@/const/auth';
import { TraceNameMap } from '@/const/trace';
Expand Down
2 changes: 1 addition & 1 deletion src/libs/trpc/middleware/jwtPayload.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { TRPCError } from '@trpc/server';
import { beforeEach, describe, expect, it, vi } from 'vitest';

import * as utils from '@/app/api/middleware/auth/utils';
import * as utils from '@/app/(backend)/api/middleware/auth/utils';
import { createCallerFactory } from '@/libs/trpc';
import { trpc } from '@/libs/trpc/init';
import { AuthContext, createContextInner } from '@/server/context';
Expand Down
2 changes: 1 addition & 1 deletion src/libs/trpc/middleware/jwtPayload.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TRPCError } from '@trpc/server';

import { getJWTPayload } from '@/app/api/middleware/auth/utils';
import { getJWTPayload } from '@/app/(backend)/api/middleware/auth/utils';
import { trpc } from '@/libs/trpc/init';

export const jwtPayloadChecker = trpc.middleware(async (opts) => {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/trpc/middleware/keyVaults.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TRPCError } from '@trpc/server';

import { getJWTPayload } from '@/app/api/middleware/auth/utils';
import { getJWTPayload } from '@/app/(backend)/api/middleware/auth/utils';
import { trpc } from '@/libs/trpc/init';

export const keyVaults = trpc.middleware(async (opts) => {
Expand Down
2 changes: 1 addition & 1 deletion src/server/routers/async/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { chunk } from 'lodash-es';
import pMap from 'p-map';
import { z } from 'zod';

import { initAgentRuntimeWithUserPayload } from '@/app/api/chat/agentRuntime';
import { initAgentRuntimeWithUserPayload } from '@/app/(backend)/api/chat/agentRuntime';
import { fileEnv } from '@/config/file';
import { DEFAULT_EMBEDDING_MODEL } from '@/const/settings';
import { ASYNC_TASK_TIMEOUT, AsyncTaskModel } from '@/database/server/models/asyncTask';
Expand Down
2 changes: 1 addition & 1 deletion src/server/routers/async/ragEval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TRPCError } from '@trpc/server';
import OpenAI from 'openai';
import { z } from 'zod';

import { initAgentRuntimeWithUserPayload } from '@/app/api/chat/agentRuntime';
import { initAgentRuntimeWithUserPayload } from '@/app/(backend)/api/chat/agentRuntime';
import { chainAnswerWithContext } from '@/chains/answerWithContext';
import { DEFAULT_EMBEDDING_MODEL, DEFAULT_MODEL } from '@/const/settings';
import { ChunkModel } from '@/database/server/models/chunk';
Expand Down
2 changes: 1 addition & 1 deletion src/server/routers/lambda/chunk.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { inArray } from 'drizzle-orm';
import { z } from 'zod';

import { initAgentRuntimeWithUserPayload } from '@/app/api/chat/agentRuntime';
import { initAgentRuntimeWithUserPayload } from '@/app/(backend)/api/chat/agentRuntime';
import { DEFAULT_EMBEDDING_MODEL } from '@/const/settings';
import { serverDB } from '@/database/server';
import { AsyncTaskModel } from '@/database/server/models/asyncTask';
Expand Down
2 changes: 1 addition & 1 deletion src/services/_url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const API_ENDPOINTS = mapWithBasePath({
trace: '/webapi/trace',

// image
images: '/webapi/api/text-to-image/openai',
images: '/webapi/text-to-image/openai',

// STT
stt: '/webapi/stt/openai',
Expand Down
Loading

0 comments on commit f66decf

Please sign in to comment.