github-actions[bot] commited on
Commit
1ac4e1d
·
1 Parent(s): e434d49

Update from GitHub Actions

Browse files
Files changed (1) hide show
  1. src/dust-client.js +6 -6
src/dust-client.js CHANGED
@@ -310,10 +310,15 @@ export class DustClient {
310
  * Combines all messages into a single context string for Dust API
311
  */
312
  buildConversationContext(messages) {
313
- if (!messages || !Array.isArray(messages)) {
314
  return '';
315
  }
316
 
 
 
 
 
 
317
  // 将所有消息格式化为对话上下文
318
  const contextParts = messages.map(msg => {
319
  const role = msg.role === 'assistant' ? 'Assistant' :
@@ -321,11 +326,6 @@ export class DustClient {
321
  return `${role}: ${msg.content}`;
322
  });
323
 
324
- // 如果有多条消息,添加上下文说明;如果只有一条消息,直接返回内容
325
- if (messages.length === 1) {
326
- return messages[0].content;
327
- }
328
-
329
  // 添加当前请求的标识
330
  contextParts.push('Please respond to the above conversation.');
331
 
 
310
  * Combines all messages into a single context string for Dust API
311
  */
312
  buildConversationContext(messages) {
313
+ if (!messages || !Array.isArray(messages) || messages.length === 0) {
314
  return '';
315
  }
316
 
317
+ // 如果只有一条消息,直接返回内容
318
+ if (messages.length === 1) {
319
+ return messages[0].content;
320
+ }
321
+
322
  // 将所有消息格式化为对话上下文
323
  const contextParts = messages.map(msg => {
324
  const role = msg.role === 'assistant' ? 'Assistant' :
 
326
  return `${role}: ${msg.content}`;
327
  });
328
 
 
 
 
 
 
329
  // 添加当前请求的标识
330
  contextParts.push('Please respond to the above conversation.');
331