@lobehub/chat 0.90.1 → 0.90.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/package.json +1 -1
- package/src/app/api/openai/{createChatCompletion.ts → chat/createChatCompletion.ts} +2 -2
- package/src/app/api/openai/chat/route.ts +3 -3
- package/src/prompts/agent.ts +4 -4
- package/src/prompts/chat.ts +2 -2
- package/src/services/chatModel.ts +2 -2
- package/src/store/plugin/selectors.ts +1 -1
- package/src/store/session/slices/chat/helpers.ts +1 -1
- package/src/types/{openai.ts → openai/chat.ts} +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.90.2](https://github.com/lobehub/lobe-chat/compare/v0.90.1...v0.90.2)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2023-10-17**</sup>
|
|
8
|
+
|
|
9
|
+
#### ♻ Code Refactoring
|
|
10
|
+
|
|
11
|
+
- **misc**: Refactor OpenAIStreamPayload with chat name.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### Code refactoring
|
|
19
|
+
|
|
20
|
+
- **misc**: Refactor OpenAIStreamPayload with chat name ([a799530](https://github.com/lobehub/lobe-chat/commit/a799530))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
### [Version 0.90.1](https://github.com/lobehub/lobe-chat/compare/v0.90.0...v0.90.1)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2023-10-17**</sup>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.90.
|
|
3
|
+
"version": "0.90.2",
|
|
4
4
|
"description": "An open-source, extensible (Function Calling), high-performance chatbot framework. It supports one-click free deployment of your private ChatGPT/LLM web application",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chatbot",
|
|
@@ -3,11 +3,11 @@ import OpenAI from 'openai';
|
|
|
3
3
|
|
|
4
4
|
import { createErrorResponse } from '@/app/api/openai/errorResponse';
|
|
5
5
|
import { ChatErrorType } from '@/types/fetch';
|
|
6
|
-
import {
|
|
6
|
+
import { OpenAIChatStreamPayload } from '@/types/openai/chat';
|
|
7
7
|
|
|
8
8
|
interface CreateChatCompletionOptions {
|
|
9
9
|
openai: OpenAI;
|
|
10
|
-
payload:
|
|
10
|
+
payload: OpenAIChatStreamPayload;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export const createChatCompletion = async ({ payload, openai }: CreateChatCompletionOptions) => {
|
|
@@ -3,18 +3,18 @@ import OpenAI from 'openai';
|
|
|
3
3
|
import { getServerConfig } from '@/config/server';
|
|
4
4
|
import { getOpenAIAuthFromRequest } from '@/const/fetch';
|
|
5
5
|
import { ChatErrorType, ErrorType } from '@/types/fetch';
|
|
6
|
-
import {
|
|
6
|
+
import { OpenAIChatStreamPayload } from '@/types/openai/chat';
|
|
7
7
|
|
|
8
8
|
import { checkAuth } from '../../auth';
|
|
9
9
|
import { createAzureOpenai } from '../createAzureOpenai';
|
|
10
|
-
import { createChatCompletion } from '../createChatCompletion';
|
|
11
10
|
import { createOpenai } from '../createOpenai';
|
|
12
11
|
import { createErrorResponse } from '../errorResponse';
|
|
12
|
+
import { createChatCompletion } from './createChatCompletion';
|
|
13
13
|
|
|
14
14
|
export const runtime = 'edge';
|
|
15
15
|
|
|
16
16
|
export const POST = async (req: Request) => {
|
|
17
|
-
const payload = (await req.json()) as
|
|
17
|
+
const payload = (await req.json()) as OpenAIChatStreamPayload;
|
|
18
18
|
|
|
19
19
|
const { apiKey, accessCode, endpoint, useAzure, apiVersion } = getOpenAIAuthFromRequest(req);
|
|
20
20
|
|
package/src/prompts/agent.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OpenAIChatStreamPayload } from '@/types/openai/chat';
|
|
2
2
|
|
|
3
3
|
// 自动起名
|
|
4
|
-
export const promptSummaryAgentName = (content: string): Partial<
|
|
4
|
+
export const promptSummaryAgentName = (content: string): Partial<OpenAIChatStreamPayload> => ({
|
|
5
5
|
messages: [
|
|
6
6
|
{
|
|
7
7
|
content: `你是一名擅长起名的起名大师,你需要将用户的描述总结为 20 个字以内的角色,格式要求如下:
|
|
@@ -32,7 +32,7 @@ export const promptSummaryAgentName = (content: string): Partial<OpenAIStreamPay
|
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
// 自动挑选 emoji 和背景色
|
|
35
|
-
export const promptPickEmoji = (content: string): Partial<
|
|
35
|
+
export const promptPickEmoji = (content: string): Partial<OpenAIChatStreamPayload> => ({
|
|
36
36
|
messages: [
|
|
37
37
|
{
|
|
38
38
|
content: '你是一名非常懂设计与时尚的设计师,你需要从用户的描述中匹配一个合适的 emoji。',
|
|
@@ -61,7 +61,7 @@ export const promptPickEmoji = (content: string): Partial<OpenAIStreamPayload> =
|
|
|
61
61
|
],
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
-
export const promptSummaryDescription = (content: string): Partial<
|
|
64
|
+
export const promptSummaryDescription = (content: string): Partial<OpenAIChatStreamPayload> => ({
|
|
65
65
|
messages: [
|
|
66
66
|
{
|
|
67
67
|
content:
|
package/src/prompts/chat.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { chatHelpers } from '@/store/session/helpers';
|
|
2
2
|
import { LanguageModel } from '@/types/llm';
|
|
3
|
-
import { OpenAIChatMessage,
|
|
3
|
+
import { OpenAIChatMessage, OpenAIChatStreamPayload } from '@/types/openai/chat';
|
|
4
4
|
|
|
5
5
|
export const promptSummaryTitle = async (
|
|
6
6
|
messages: OpenAIChatMessage[],
|
|
7
|
-
): Promise<Partial<
|
|
7
|
+
): Promise<Partial<OpenAIChatStreamPayload>> => {
|
|
8
8
|
const finalMessages: OpenAIChatMessage[] = [
|
|
9
9
|
{
|
|
10
10
|
content:
|
|
@@ -2,7 +2,7 @@ import { merge } from 'lodash-es';
|
|
|
2
2
|
|
|
3
3
|
import { pluginSelectors, usePluginStore } from '@/store/plugin';
|
|
4
4
|
import { initialLobeAgentConfig } from '@/store/session/initialState';
|
|
5
|
-
import type { ChatCompletionFunctions,
|
|
5
|
+
import type { ChatCompletionFunctions, OpenAIChatStreamPayload } from '@/types/openai/chat';
|
|
6
6
|
|
|
7
7
|
import { createHeaderWithOpenAI } from './_header';
|
|
8
8
|
import { OPENAI_URLS } from './_url';
|
|
@@ -15,7 +15,7 @@ interface FetchChatModelOptions {
|
|
|
15
15
|
* 专门用于对话的 fetch
|
|
16
16
|
*/
|
|
17
17
|
export const fetchChatModel = (
|
|
18
|
-
{ plugins: enabledPlugins, ...params }: Partial<
|
|
18
|
+
{ plugins: enabledPlugins, ...params }: Partial<OpenAIChatStreamPayload>,
|
|
19
19
|
options?: FetchChatModelOptions,
|
|
20
20
|
) => {
|
|
21
21
|
const payload = merge(
|
|
@@ -2,7 +2,7 @@ import { uniqBy } from 'lodash-es';
|
|
|
2
2
|
|
|
3
3
|
import { PLUGIN_SCHEMA_SEPARATOR } from '@/const/plugin';
|
|
4
4
|
import { pluginHelpers } from '@/store/plugin/helpers';
|
|
5
|
-
import { ChatCompletionFunctions } from '@/types/openai';
|
|
5
|
+
import { ChatCompletionFunctions } from '@/types/openai/chat';
|
|
6
6
|
|
|
7
7
|
import { PluginStoreState } from './initialState';
|
|
8
8
|
|