@lobehub/chat 1.62.1 → 1.62.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 CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.62.2](https://github.com/lobehub/lobe-chat/compare/v1.62.1...v1.62.2)
6
+
7
+ <sup>Released on **2025-02-20**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Fix message roles for specific Azure OpenAI models.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fix message roles for specific Azure OpenAI models, closes [#6222](https://github.com/lobehub/lobe-chat/issues/6222) ([d49329a](https://github.com/lobehub/lobe-chat/commit/d49329a))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
5
30
  ### [Version 1.62.1](https://github.com/lobehub/lobe-chat/compare/v1.62.0...v1.62.1)
6
31
 
7
32
  <sup>Released on **2025-02-20**</sup>
package/changelog/v1.json CHANGED
@@ -1,4 +1,13 @@
1
1
  [
2
+ {
3
+ "children": {
4
+ "fixes": [
5
+ "Fix message roles for specific Azure OpenAI models."
6
+ ]
7
+ },
8
+ "date": "2025-02-20",
9
+ "version": "1.62.2"
10
+ },
2
11
  {
3
12
  "children": {
4
13
  "fixes": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.62.1",
3
+ "version": "1.62.2",
4
4
  "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.",
5
5
  "keywords": [
6
6
  "framework",
@@ -159,7 +159,7 @@
159
159
  "drizzle-orm": "^0.39.0",
160
160
  "drizzle-zod": "^0.5.1",
161
161
  "fast-deep-equal": "^3.1.3",
162
- "file-type": "^19.6.0",
162
+ "file-type": "^20.0.0",
163
163
  "framer-motion": "^11.16.0",
164
164
  "gpt-tokenizer": "^2.8.1",
165
165
  "i18next": "^24.2.1",
@@ -33,9 +33,28 @@ export class LobeAzureOpenAI implements LobeRuntimeAI {
33
33
  const { messages, model, ...params } = payload;
34
34
  // o1 series models on Azure OpenAI does not support streaming currently
35
35
  const enableStreaming = model.includes('o1') ? false : (params.stream ?? true);
36
+
37
+ // Convert 'system' role to 'user' or 'developer' based on the model
38
+ const systemToUserModels = new Set([
39
+ 'o1-preview',
40
+ 'o1-preview-2024-09-12',
41
+ 'o1-mini',
42
+ 'o1-mini-2024-09-12',
43
+ ]);
44
+
45
+ const updatedMessages = messages.map((message) => ({
46
+ ...message,
47
+ role:
48
+ (model.includes('o1') || model.includes('o3')) && message.role === 'system'
49
+ ? [...systemToUserModels].some((sub) => model.includes(sub))
50
+ ? 'user'
51
+ : 'developer'
52
+ : message.role,
53
+ }));
54
+
36
55
  try {
37
56
  const response = await this.client.chat.completions.create({
38
- messages: messages as OpenAI.ChatCompletionMessageParam[],
57
+ messages: updatedMessages as OpenAI.ChatCompletionMessageParam[],
39
58
  model,
40
59
  ...params,
41
60
  max_completion_tokens: null,