@xpert-ai/plugin-sdk 3.16.0 → 3.16.1

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
@@ -1,5 +1,11 @@
1
1
  # @xpert-ai/plugin-sdk
2
2
 
3
+ ## 3.16.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 57721a6: Normalize missing assistant roles in OpenAI-compatible completion responses.
8
+
3
9
  ## 3.16.0
4
10
 
5
11
  ### Minor Changes
package/index.cjs.js CHANGED
@@ -2679,7 +2679,12 @@ function isValidTokenCount(value) {
2679
2679
  *
2680
2680
  */ _convertCompletionsDeltaToBaseMessageChunk(// eslint-disable-next-line @typescript-eslint/no-explicit-any
2681
2681
  delta, rawResponse, defaultRole) {
2682
- const messageChunk = super._convertCompletionsDeltaToBaseMessageChunk(delta, rawResponse, defaultRole);
2682
+ // Some OpenAI-compatible providers omit `delta.role` on the final usage
2683
+ // chunk. Without a role, LangChain creates a generic ChatMessageChunk;
2684
+ // persisting that chunk makes the next request contain `role: undefined`.
2685
+ // Treat role-less completion deltas as assistant output so they remain
2686
+ // valid both in the current stream and when the conversation is resumed.
2687
+ const messageChunk = super._convertCompletionsDeltaToBaseMessageChunk(delta, rawResponse, defaultRole != null ? defaultRole : 'assistant');
2683
2688
  if (delta['content'] === '<think>') {
2684
2689
  this.thinking = true;
2685
2690
  messageChunk.content = '';
@@ -2695,7 +2700,14 @@ function isValidTokenCount(value) {
2695
2700
  return messageChunk;
2696
2701
  }
2697
2702
  _convertCompletionsMessageToBaseMessage(message, rawResponse) {
2698
- const langChainMessage = super._convertCompletionsMessageToBaseMessage(message, rawResponse);
2703
+ var _message_role;
2704
+ // Some compatible providers also omit the role on non-stream responses.
2705
+ // Normalize that response before LangChain falls back to a generic
2706
+ // message with role `unknown`.
2707
+ const normalizedMessage = collaborationClient._extends({}, message, {
2708
+ role: (_message_role = message.role) != null ? _message_role : 'assistant'
2709
+ });
2710
+ const langChainMessage = super._convertCompletionsMessageToBaseMessage(normalizedMessage, rawResponse);
2699
2711
  console.log(langChainMessage.content);
2700
2712
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2701
2713
  if (message.reasoning_content) {
package/index.esm.js CHANGED
@@ -2661,7 +2661,12 @@ function isValidTokenCount(value) {
2661
2661
  *
2662
2662
  */ _convertCompletionsDeltaToBaseMessageChunk(// eslint-disable-next-line @typescript-eslint/no-explicit-any
2663
2663
  delta, rawResponse, defaultRole) {
2664
- const messageChunk = super._convertCompletionsDeltaToBaseMessageChunk(delta, rawResponse, defaultRole);
2664
+ // Some OpenAI-compatible providers omit `delta.role` on the final usage
2665
+ // chunk. Without a role, LangChain creates a generic ChatMessageChunk;
2666
+ // persisting that chunk makes the next request contain `role: undefined`.
2667
+ // Treat role-less completion deltas as assistant output so they remain
2668
+ // valid both in the current stream and when the conversation is resumed.
2669
+ const messageChunk = super._convertCompletionsDeltaToBaseMessageChunk(delta, rawResponse, defaultRole != null ? defaultRole : 'assistant');
2665
2670
  if (delta['content'] === '<think>') {
2666
2671
  this.thinking = true;
2667
2672
  messageChunk.content = '';
@@ -2677,7 +2682,14 @@ function isValidTokenCount(value) {
2677
2682
  return messageChunk;
2678
2683
  }
2679
2684
  _convertCompletionsMessageToBaseMessage(message, rawResponse) {
2680
- const langChainMessage = super._convertCompletionsMessageToBaseMessage(message, rawResponse);
2685
+ var _message_role;
2686
+ // Some compatible providers also omit the role on non-stream responses.
2687
+ // Normalize that response before LangChain falls back to a generic
2688
+ // message with role `unknown`.
2689
+ const normalizedMessage = _extends({}, message, {
2690
+ role: (_message_role = message.role) != null ? _message_role : 'assistant'
2691
+ });
2692
+ const langChainMessage = super._convertCompletionsMessageToBaseMessage(normalizedMessage, rawResponse);
2681
2693
  console.log(langChainMessage.content);
2682
2694
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2683
2695
  if (message.reasoning_content) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpert-ai/plugin-sdk",
3
- "version": "3.16.0",
3
+ "version": "3.16.1",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",