@ai-sdk%[email protected] 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. diff --git a/dist/index.mjs b/dist/index.mjs
  2. --- a/dist/index.mjs
  3. +++ b/dist/index.mjs
  4. @@ -959,7 +959,7 @@
  5. model: z4.string().nullish(),
  6. object: z4.literal("response"),
  7. output: z4.array(outputItemSchema),
  8. - usage: xaiResponsesUsageSchema,
  9. + usage: xaiResponsesUsageSchema.nullish(),
  10. status: z4.string()
  11. });
  12. var xaiResponsesChunkSchema = z4.union([
  13. \ No newline at end of file
  14. @@ -1143,6 +1143,18 @@
  15. z4.object({
  16. type: z4.literal("response.completed"),
  17. response: xaiResponsesResponseSchema
  18. + }),
  19. + z4.object({
  20. + type: z4.literal("response.function_call_arguments.delta"),
  21. + item_id: z4.string(),
  22. + output_index: z4.number(),
  23. + delta: z4.string()
  24. + }),
  25. + z4.object({
  26. + type: z4.literal("response.function_call_arguments.done"),
  27. + item_id: z4.string(),
  28. + output_index: z4.number(),
  29. + arguments: z4.string()
  30. })
  31. ]);
  32. \ No newline at end of file
  33. @@ -1940,6 +1952,9 @@
  34. if (response2.status) {
  35. finishReason = mapXaiResponsesFinishReason(response2.status);
  36. }
  37. + if (seenToolCalls.size > 0 && finishReason !== "tool-calls") {
  38. + finishReason = "tool-calls";
  39. + }
  40. return;
  41. }
  42. if (event.type === "response.output_item.added" || event.type === "response.output_item.done") {
  43. \ No newline at end of file
  44. @@ -2024,7 +2039,7 @@
  45. }
  46. }
  47. } else if (part.type === "function_call") {
  48. - if (!seenToolCalls.has(part.call_id)) {
  49. + if (event.type === "response.output_item.done" && !seenToolCalls.has(part.call_id)) {
  50. seenToolCalls.add(part.call_id);
  51. controller.enqueue({
  52. type: "tool-input-start",
  53. \ No newline at end of file
  54. diff --git a/dist/index.js b/dist/index.js
  55. --- a/dist/index.js
  56. +++ b/dist/index.js
  57. @@ -964,7 +964,7 @@
  58. model: import_v44.z.string().nullish(),
  59. object: import_v44.z.literal("response"),
  60. output: import_v44.z.array(outputItemSchema),
  61. - usage: xaiResponsesUsageSchema,
  62. + usage: xaiResponsesUsageSchema.nullish(),
  63. status: import_v44.z.string()
  64. });
  65. var xaiResponsesChunkSchema = import_v44.z.union([
  66. \ No newline at end of file
  67. @@ -1148,6 +1148,18 @@
  68. import_v44.z.object({
  69. type: import_v44.z.literal("response.completed"),
  70. response: xaiResponsesResponseSchema
  71. + }),
  72. + import_v44.z.object({
  73. + type: import_v44.z.literal("response.function_call_arguments.delta"),
  74. + item_id: import_v44.z.string(),
  75. + output_index: import_v44.z.number(),
  76. + delta: import_v44.z.string()
  77. + }),
  78. + import_v44.z.object({
  79. + type: import_v44.z.literal("response.function_call_arguments.done"),
  80. + item_id: import_v44.z.string(),
  81. + output_index: import_v44.z.number(),
  82. + arguments: import_v44.z.string()
  83. })
  84. ]);
  85. \ No newline at end of file
  86. @@ -1935,6 +1947,9 @@
  87. if (response2.status) {
  88. finishReason = mapXaiResponsesFinishReason(response2.status);
  89. }
  90. + if (seenToolCalls.size > 0 && finishReason !== "tool-calls") {
  91. + finishReason = "tool-calls";
  92. + }
  93. return;
  94. }
  95. if (event.type === "response.output_item.added" || event.type === "response.output_item.done") {
  96. \ No newline at end of file
  97. @@ -2019,7 +2034,7 @@
  98. }
  99. }
  100. } else if (part.type === "function_call") {
  101. - if (!seenToolCalls.has(part.call_id)) {
  102. + if (event.type === "response.output_item.done" && !seenToolCalls.has(part.call_id)) {
  103. seenToolCalls.add(part.call_id);
  104. controller.enqueue({
  105. type: "tool-input-start",
  106. \ No newline at end of file