@langchain/xai 1.3.9 → 1.3.10-dev-1773709997654

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.
Files changed (48) hide show
  1. package/dist/chat_models/completions.cjs +5 -6
  2. package/dist/chat_models/completions.cjs.map +1 -1
  3. package/dist/chat_models/completions.js +2 -3
  4. package/dist/chat_models/completions.js.map +1 -1
  5. package/dist/chat_models/index.cjs +2 -2
  6. package/dist/chat_models/index.js +3 -4
  7. package/dist/chat_models/responses.cjs +3 -4
  8. package/dist/chat_models/responses.cjs.map +1 -1
  9. package/dist/chat_models/responses.js +2 -3
  10. package/dist/chat_models/responses.js.map +1 -1
  11. package/dist/converters/responses.cjs +1 -2
  12. package/dist/converters/responses.cjs.map +1 -1
  13. package/dist/converters/responses.js +1 -2
  14. package/dist/converters/responses.js.map +1 -1
  15. package/dist/index.cjs +6 -7
  16. package/dist/index.d.ts +0 -1
  17. package/dist/index.js +1 -2
  18. package/dist/live_search.cjs +1 -2
  19. package/dist/live_search.cjs.map +1 -1
  20. package/dist/live_search.js +1 -1
  21. package/dist/live_search.js.map +1 -1
  22. package/dist/profiles.cjs +1 -2
  23. package/dist/profiles.cjs.map +1 -1
  24. package/dist/profiles.js +1 -1
  25. package/dist/tools/code_execution.cjs +1 -2
  26. package/dist/tools/code_execution.cjs.map +1 -1
  27. package/dist/tools/code_execution.js +1 -1
  28. package/dist/tools/collections_search.cjs +1 -2
  29. package/dist/tools/collections_search.cjs.map +1 -1
  30. package/dist/tools/collections_search.js +1 -1
  31. package/dist/tools/collections_search.js.map +1 -1
  32. package/dist/tools/index.cjs +6 -7
  33. package/dist/tools/index.cjs.map +1 -1
  34. package/dist/tools/index.js +6 -7
  35. package/dist/tools/index.js.map +1 -1
  36. package/dist/tools/live_search.cjs +1 -2
  37. package/dist/tools/live_search.cjs.map +1 -1
  38. package/dist/tools/live_search.js +1 -1
  39. package/dist/tools/live_search.js.map +1 -1
  40. package/dist/tools/web_search.cjs +1 -2
  41. package/dist/tools/web_search.cjs.map +1 -1
  42. package/dist/tools/web_search.js +1 -1
  43. package/dist/tools/web_search.js.map +1 -1
  44. package/dist/tools/x_search.cjs +1 -2
  45. package/dist/tools/x_search.cjs.map +1 -1
  46. package/dist/tools/x_search.js +1 -1
  47. package/dist/tools/x_search.js.map +1 -1
  48. package/package.json +6 -6
@@ -1,6 +1,5 @@
1
1
  let _langchain_core_messages = require("@langchain/core/messages");
2
2
  let _langchain_core_outputs = require("@langchain/core/outputs");
3
-
4
3
  //#region src/converters/responses.ts
5
4
  /**
6
5
  * Converts a single LangChain BaseMessage to xAI Responses API input format.
@@ -154,10 +153,10 @@ function convertStreamEventToChunk(event) {
154
153
  }
155
154
  return null;
156
155
  }
157
-
158
156
  //#endregion
159
157
  exports.convertMessagesToResponsesInput = convertMessagesToResponsesInput;
160
158
  exports.convertResponseToAIMessage = convertResponseToAIMessage;
161
159
  exports.convertStreamEventToChunk = convertStreamEventToChunk;
162
160
  exports.extractTextFromOutput = extractTextFromOutput;
161
+
163
162
  //# sourceMappingURL=responses.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"responses.cjs","names":["AIMessage","ChatGenerationChunk","AIMessageChunk"],"sources":["../../src/converters/responses.ts"],"sourcesContent":["import {\n AIMessage,\n AIMessageChunk,\n BaseMessage,\n type UsageMetadata,\n} from \"@langchain/core/messages\";\nimport { ChatGenerationChunk } from \"@langchain/core/outputs\";\n\nimport type {\n XAIResponse,\n XAIResponsesInputItem,\n XAIResponsesMessage,\n XAIResponsesOutputContent,\n XAIResponsesOutputItem,\n XAIResponsesStreamEvent,\n XAIResponsesUsage,\n} from \"../chat_models/responses-types.js\";\n\n// ============================================================================\n// Message Converters\n// ============================================================================\n\n/**\n * Converts a single LangChain BaseMessage to xAI Responses API input format.\n *\n * @param message - The LangChain message to convert\n * @returns The xAI Responses API input item\n */\nexport function convertMessageToResponsesInput(\n message: BaseMessage\n): XAIResponsesInputItem {\n if (message.type === \"human\") {\n const content =\n typeof message.content === \"string\"\n ? message.content\n : message.content.map((part) => {\n if (typeof part === \"string\") {\n return { type: \"input_text\" as const, text: part };\n }\n if (part.type === \"text\") {\n return { type: \"input_text\" as const, text: part.text };\n }\n if (part.type === \"image_url\") {\n const imageUrlPart = part as {\n type: \"image_url\";\n image_url: string | { url: string };\n };\n const imageUrl =\n typeof imageUrlPart.image_url === \"string\"\n ? imageUrlPart.image_url\n : imageUrlPart.image_url.url;\n return {\n type: \"input_image\" as const,\n image_url: imageUrl,\n detail: \"auto\" as const,\n };\n }\n return { type: \"input_text\" as const, text: \"\" };\n });\n\n return {\n role: \"user\",\n content,\n } as XAIResponsesMessage;\n }\n\n if (message.type === \"system\") {\n return {\n role: \"system\",\n content:\n typeof message.content === \"string\"\n ? message.content\n : message.content\n .map((part) =>\n typeof part === \"string\" ? part : part.text || \"\"\n )\n .join(\"\"),\n } as XAIResponsesMessage;\n }\n\n if (message.type === \"ai\") {\n const aiMessage = message as AIMessage;\n return {\n type: \"message\",\n role: \"assistant\",\n text: typeof aiMessage.content === \"string\" ? aiMessage.content : \"\",\n } as unknown as XAIResponsesInputItem;\n }\n\n // Default fallback\n return {\n role: \"user\",\n content:\n typeof message.content === \"string\"\n ? message.content\n : JSON.stringify(message.content),\n } as XAIResponsesMessage;\n}\n\n/**\n * Converts an array of LangChain BaseMessages to xAI Responses API input format.\n *\n * @param messages - Array of LangChain messages to convert\n * @returns Array of xAI Responses API input items\n */\nexport function convertMessagesToResponsesInput(\n messages: BaseMessage[]\n): XAIResponsesInputItem[] {\n return messages.map(convertMessageToResponsesInput);\n}\n\n// ============================================================================\n// Usage Converters\n// ============================================================================\n\n/**\n * Converts xAI usage statistics to LangChain UsageMetadata format.\n *\n * @param usage - The xAI usage statistics\n * @returns LangChain UsageMetadata object\n */\nexport function convertUsageToUsageMetadata(\n usage: XAIResponsesUsage | null | undefined\n): UsageMetadata {\n return {\n input_tokens: usage?.input_tokens ?? 0,\n output_tokens: usage?.output_tokens ?? 0,\n total_tokens: usage?.total_tokens ?? 0,\n input_token_details: {\n ...(usage?.input_tokens_details?.cached_tokens != null && {\n cache_read: usage.input_tokens_details.cached_tokens,\n }),\n },\n output_token_details: {\n ...(usage?.output_tokens_details?.reasoning_tokens != null && {\n reasoning: usage.output_tokens_details.reasoning_tokens,\n }),\n },\n };\n}\n\n// ============================================================================\n// Output Converters\n// ============================================================================\n\n/**\n * Extracts text content from xAI response output items.\n *\n * @param output - Array of xAI response output items\n * @returns Concatenated text content\n */\nexport function extractTextFromOutput(\n output: XAIResponsesOutputItem[]\n): string {\n const textParts: string[] = [];\n\n for (const item of output) {\n if (item.type === \"message\" && \"content\" in item) {\n for (const contentItem of item.content as XAIResponsesOutputContent[]) {\n if (contentItem.type === \"output_text\") {\n textParts.push(contentItem.text);\n }\n }\n }\n }\n\n return textParts.join(\"\");\n}\n\n/**\n * Converts an xAI Response to a LangChain AIMessage.\n *\n * @param response - The xAI API response\n * @returns LangChain AIMessage\n */\nexport function convertResponseToAIMessage(response: XAIResponse): AIMessage {\n const text = extractTextFromOutput(response.output);\n\n const responseMetadata: Record<string, unknown> = {\n model_provider: \"xai\",\n model: response.model,\n created_at: response.created_at,\n id: response.id,\n status: response.status,\n object: response.object,\n };\n\n if (response.incomplete_details) {\n responseMetadata.incomplete_details = response.incomplete_details;\n }\n\n return new AIMessage({\n content: text,\n usage_metadata: convertUsageToUsageMetadata(response.usage),\n response_metadata: responseMetadata,\n additional_kwargs: {\n ...(response.reasoning && { reasoning: response.reasoning }),\n },\n });\n}\n\n// ============================================================================\n// Streaming Converters\n// ============================================================================\n\n/**\n * Converts an xAI streaming event to a LangChain ChatGenerationChunk.\n *\n * @param event - The xAI streaming event\n * @returns ChatGenerationChunk or null if the event doesn't produce a chunk\n */\nexport function convertStreamEventToChunk(\n event: XAIResponsesStreamEvent\n): ChatGenerationChunk | null {\n const responseMetadata: Record<string, unknown> = {\n model_provider: \"xai\",\n };\n\n if (event.type === \"response.output_text.delta\") {\n return new ChatGenerationChunk({\n text: event.delta,\n message: new AIMessageChunk({\n content: event.delta,\n response_metadata: responseMetadata,\n }),\n });\n }\n\n if (event.type === \"response.created\") {\n responseMetadata.id = event.response.id;\n responseMetadata.model = event.response.model;\n return new ChatGenerationChunk({\n text: \"\",\n message: new AIMessageChunk({\n content: \"\",\n response_metadata: responseMetadata,\n }),\n });\n }\n\n if (event.type === \"response.completed\") {\n const aiMessage = convertResponseToAIMessage(event.response);\n return new ChatGenerationChunk({\n text: \"\",\n message: new AIMessageChunk({\n content: \"\",\n usage_metadata: aiMessage.usage_metadata,\n response_metadata: {\n ...responseMetadata,\n ...aiMessage.response_metadata,\n },\n }),\n });\n }\n\n return null;\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"responses.cjs","names":["AIMessage","ChatGenerationChunk","AIMessageChunk"],"sources":["../../src/converters/responses.ts"],"sourcesContent":["import {\n AIMessage,\n AIMessageChunk,\n BaseMessage,\n type UsageMetadata,\n} from \"@langchain/core/messages\";\nimport { ChatGenerationChunk } from \"@langchain/core/outputs\";\n\nimport type {\n XAIResponse,\n XAIResponsesInputItem,\n XAIResponsesMessage,\n XAIResponsesOutputContent,\n XAIResponsesOutputItem,\n XAIResponsesStreamEvent,\n XAIResponsesUsage,\n} from \"../chat_models/responses-types.js\";\n\n// ============================================================================\n// Message Converters\n// ============================================================================\n\n/**\n * Converts a single LangChain BaseMessage to xAI Responses API input format.\n *\n * @param message - The LangChain message to convert\n * @returns The xAI Responses API input item\n */\nexport function convertMessageToResponsesInput(\n message: BaseMessage\n): XAIResponsesInputItem {\n if (message.type === \"human\") {\n const content =\n typeof message.content === \"string\"\n ? message.content\n : message.content.map((part) => {\n if (typeof part === \"string\") {\n return { type: \"input_text\" as const, text: part };\n }\n if (part.type === \"text\") {\n return { type: \"input_text\" as const, text: part.text };\n }\n if (part.type === \"image_url\") {\n const imageUrlPart = part as {\n type: \"image_url\";\n image_url: string | { url: string };\n };\n const imageUrl =\n typeof imageUrlPart.image_url === \"string\"\n ? imageUrlPart.image_url\n : imageUrlPart.image_url.url;\n return {\n type: \"input_image\" as const,\n image_url: imageUrl,\n detail: \"auto\" as const,\n };\n }\n return { type: \"input_text\" as const, text: \"\" };\n });\n\n return {\n role: \"user\",\n content,\n } as XAIResponsesMessage;\n }\n\n if (message.type === \"system\") {\n return {\n role: \"system\",\n content:\n typeof message.content === \"string\"\n ? message.content\n : message.content\n .map((part) =>\n typeof part === \"string\" ? part : part.text || \"\"\n )\n .join(\"\"),\n } as XAIResponsesMessage;\n }\n\n if (message.type === \"ai\") {\n const aiMessage = message as AIMessage;\n return {\n type: \"message\",\n role: \"assistant\",\n text: typeof aiMessage.content === \"string\" ? aiMessage.content : \"\",\n } as unknown as XAIResponsesInputItem;\n }\n\n // Default fallback\n return {\n role: \"user\",\n content:\n typeof message.content === \"string\"\n ? message.content\n : JSON.stringify(message.content),\n } as XAIResponsesMessage;\n}\n\n/**\n * Converts an array of LangChain BaseMessages to xAI Responses API input format.\n *\n * @param messages - Array of LangChain messages to convert\n * @returns Array of xAI Responses API input items\n */\nexport function convertMessagesToResponsesInput(\n messages: BaseMessage[]\n): XAIResponsesInputItem[] {\n return messages.map(convertMessageToResponsesInput);\n}\n\n// ============================================================================\n// Usage Converters\n// ============================================================================\n\n/**\n * Converts xAI usage statistics to LangChain UsageMetadata format.\n *\n * @param usage - The xAI usage statistics\n * @returns LangChain UsageMetadata object\n */\nexport function convertUsageToUsageMetadata(\n usage: XAIResponsesUsage | null | undefined\n): UsageMetadata {\n return {\n input_tokens: usage?.input_tokens ?? 0,\n output_tokens: usage?.output_tokens ?? 0,\n total_tokens: usage?.total_tokens ?? 0,\n input_token_details: {\n ...(usage?.input_tokens_details?.cached_tokens != null && {\n cache_read: usage.input_tokens_details.cached_tokens,\n }),\n },\n output_token_details: {\n ...(usage?.output_tokens_details?.reasoning_tokens != null && {\n reasoning: usage.output_tokens_details.reasoning_tokens,\n }),\n },\n };\n}\n\n// ============================================================================\n// Output Converters\n// ============================================================================\n\n/**\n * Extracts text content from xAI response output items.\n *\n * @param output - Array of xAI response output items\n * @returns Concatenated text content\n */\nexport function extractTextFromOutput(\n output: XAIResponsesOutputItem[]\n): string {\n const textParts: string[] = [];\n\n for (const item of output) {\n if (item.type === \"message\" && \"content\" in item) {\n for (const contentItem of item.content as XAIResponsesOutputContent[]) {\n if (contentItem.type === \"output_text\") {\n textParts.push(contentItem.text);\n }\n }\n }\n }\n\n return textParts.join(\"\");\n}\n\n/**\n * Converts an xAI Response to a LangChain AIMessage.\n *\n * @param response - The xAI API response\n * @returns LangChain AIMessage\n */\nexport function convertResponseToAIMessage(response: XAIResponse): AIMessage {\n const text = extractTextFromOutput(response.output);\n\n const responseMetadata: Record<string, unknown> = {\n model_provider: \"xai\",\n model: response.model,\n created_at: response.created_at,\n id: response.id,\n status: response.status,\n object: response.object,\n };\n\n if (response.incomplete_details) {\n responseMetadata.incomplete_details = response.incomplete_details;\n }\n\n return new AIMessage({\n content: text,\n usage_metadata: convertUsageToUsageMetadata(response.usage),\n response_metadata: responseMetadata,\n additional_kwargs: {\n ...(response.reasoning && { reasoning: response.reasoning }),\n },\n });\n}\n\n// ============================================================================\n// Streaming Converters\n// ============================================================================\n\n/**\n * Converts an xAI streaming event to a LangChain ChatGenerationChunk.\n *\n * @param event - The xAI streaming event\n * @returns ChatGenerationChunk or null if the event doesn't produce a chunk\n */\nexport function convertStreamEventToChunk(\n event: XAIResponsesStreamEvent\n): ChatGenerationChunk | null {\n const responseMetadata: Record<string, unknown> = {\n model_provider: \"xai\",\n };\n\n if (event.type === \"response.output_text.delta\") {\n return new ChatGenerationChunk({\n text: event.delta,\n message: new AIMessageChunk({\n content: event.delta,\n response_metadata: responseMetadata,\n }),\n });\n }\n\n if (event.type === \"response.created\") {\n responseMetadata.id = event.response.id;\n responseMetadata.model = event.response.model;\n return new ChatGenerationChunk({\n text: \"\",\n message: new AIMessageChunk({\n content: \"\",\n response_metadata: responseMetadata,\n }),\n });\n }\n\n if (event.type === \"response.completed\") {\n const aiMessage = convertResponseToAIMessage(event.response);\n return new ChatGenerationChunk({\n text: \"\",\n message: new AIMessageChunk({\n content: \"\",\n usage_metadata: aiMessage.usage_metadata,\n response_metadata: {\n ...responseMetadata,\n ...aiMessage.response_metadata,\n },\n }),\n });\n }\n\n return null;\n}\n"],"mappings":"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"}
@@ -1,6 +1,5 @@
1
1
  import { AIMessage, AIMessageChunk } from "@langchain/core/messages";
2
2
  import { ChatGenerationChunk } from "@langchain/core/outputs";
3
-
4
3
  //#region src/converters/responses.ts
5
4
  /**
6
5
  * Converts a single LangChain BaseMessage to xAI Responses API input format.
@@ -154,7 +153,7 @@ function convertStreamEventToChunk(event) {
154
153
  }
155
154
  return null;
156
155
  }
157
-
158
156
  //#endregion
159
157
  export { convertMessagesToResponsesInput, convertResponseToAIMessage, convertStreamEventToChunk, extractTextFromOutput };
158
+
160
159
  //# sourceMappingURL=responses.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"responses.js","names":[],"sources":["../../src/converters/responses.ts"],"sourcesContent":["import {\n AIMessage,\n AIMessageChunk,\n BaseMessage,\n type UsageMetadata,\n} from \"@langchain/core/messages\";\nimport { ChatGenerationChunk } from \"@langchain/core/outputs\";\n\nimport type {\n XAIResponse,\n XAIResponsesInputItem,\n XAIResponsesMessage,\n XAIResponsesOutputContent,\n XAIResponsesOutputItem,\n XAIResponsesStreamEvent,\n XAIResponsesUsage,\n} from \"../chat_models/responses-types.js\";\n\n// ============================================================================\n// Message Converters\n// ============================================================================\n\n/**\n * Converts a single LangChain BaseMessage to xAI Responses API input format.\n *\n * @param message - The LangChain message to convert\n * @returns The xAI Responses API input item\n */\nexport function convertMessageToResponsesInput(\n message: BaseMessage\n): XAIResponsesInputItem {\n if (message.type === \"human\") {\n const content =\n typeof message.content === \"string\"\n ? message.content\n : message.content.map((part) => {\n if (typeof part === \"string\") {\n return { type: \"input_text\" as const, text: part };\n }\n if (part.type === \"text\") {\n return { type: \"input_text\" as const, text: part.text };\n }\n if (part.type === \"image_url\") {\n const imageUrlPart = part as {\n type: \"image_url\";\n image_url: string | { url: string };\n };\n const imageUrl =\n typeof imageUrlPart.image_url === \"string\"\n ? imageUrlPart.image_url\n : imageUrlPart.image_url.url;\n return {\n type: \"input_image\" as const,\n image_url: imageUrl,\n detail: \"auto\" as const,\n };\n }\n return { type: \"input_text\" as const, text: \"\" };\n });\n\n return {\n role: \"user\",\n content,\n } as XAIResponsesMessage;\n }\n\n if (message.type === \"system\") {\n return {\n role: \"system\",\n content:\n typeof message.content === \"string\"\n ? message.content\n : message.content\n .map((part) =>\n typeof part === \"string\" ? part : part.text || \"\"\n )\n .join(\"\"),\n } as XAIResponsesMessage;\n }\n\n if (message.type === \"ai\") {\n const aiMessage = message as AIMessage;\n return {\n type: \"message\",\n role: \"assistant\",\n text: typeof aiMessage.content === \"string\" ? aiMessage.content : \"\",\n } as unknown as XAIResponsesInputItem;\n }\n\n // Default fallback\n return {\n role: \"user\",\n content:\n typeof message.content === \"string\"\n ? message.content\n : JSON.stringify(message.content),\n } as XAIResponsesMessage;\n}\n\n/**\n * Converts an array of LangChain BaseMessages to xAI Responses API input format.\n *\n * @param messages - Array of LangChain messages to convert\n * @returns Array of xAI Responses API input items\n */\nexport function convertMessagesToResponsesInput(\n messages: BaseMessage[]\n): XAIResponsesInputItem[] {\n return messages.map(convertMessageToResponsesInput);\n}\n\n// ============================================================================\n// Usage Converters\n// ============================================================================\n\n/**\n * Converts xAI usage statistics to LangChain UsageMetadata format.\n *\n * @param usage - The xAI usage statistics\n * @returns LangChain UsageMetadata object\n */\nexport function convertUsageToUsageMetadata(\n usage: XAIResponsesUsage | null | undefined\n): UsageMetadata {\n return {\n input_tokens: usage?.input_tokens ?? 0,\n output_tokens: usage?.output_tokens ?? 0,\n total_tokens: usage?.total_tokens ?? 0,\n input_token_details: {\n ...(usage?.input_tokens_details?.cached_tokens != null && {\n cache_read: usage.input_tokens_details.cached_tokens,\n }),\n },\n output_token_details: {\n ...(usage?.output_tokens_details?.reasoning_tokens != null && {\n reasoning: usage.output_tokens_details.reasoning_tokens,\n }),\n },\n };\n}\n\n// ============================================================================\n// Output Converters\n// ============================================================================\n\n/**\n * Extracts text content from xAI response output items.\n *\n * @param output - Array of xAI response output items\n * @returns Concatenated text content\n */\nexport function extractTextFromOutput(\n output: XAIResponsesOutputItem[]\n): string {\n const textParts: string[] = [];\n\n for (const item of output) {\n if (item.type === \"message\" && \"content\" in item) {\n for (const contentItem of item.content as XAIResponsesOutputContent[]) {\n if (contentItem.type === \"output_text\") {\n textParts.push(contentItem.text);\n }\n }\n }\n }\n\n return textParts.join(\"\");\n}\n\n/**\n * Converts an xAI Response to a LangChain AIMessage.\n *\n * @param response - The xAI API response\n * @returns LangChain AIMessage\n */\nexport function convertResponseToAIMessage(response: XAIResponse): AIMessage {\n const text = extractTextFromOutput(response.output);\n\n const responseMetadata: Record<string, unknown> = {\n model_provider: \"xai\",\n model: response.model,\n created_at: response.created_at,\n id: response.id,\n status: response.status,\n object: response.object,\n };\n\n if (response.incomplete_details) {\n responseMetadata.incomplete_details = response.incomplete_details;\n }\n\n return new AIMessage({\n content: text,\n usage_metadata: convertUsageToUsageMetadata(response.usage),\n response_metadata: responseMetadata,\n additional_kwargs: {\n ...(response.reasoning && { reasoning: response.reasoning }),\n },\n });\n}\n\n// ============================================================================\n// Streaming Converters\n// ============================================================================\n\n/**\n * Converts an xAI streaming event to a LangChain ChatGenerationChunk.\n *\n * @param event - The xAI streaming event\n * @returns ChatGenerationChunk or null if the event doesn't produce a chunk\n */\nexport function convertStreamEventToChunk(\n event: XAIResponsesStreamEvent\n): ChatGenerationChunk | null {\n const responseMetadata: Record<string, unknown> = {\n model_provider: \"xai\",\n };\n\n if (event.type === \"response.output_text.delta\") {\n return new ChatGenerationChunk({\n text: event.delta,\n message: new AIMessageChunk({\n content: event.delta,\n response_metadata: responseMetadata,\n }),\n });\n }\n\n if (event.type === \"response.created\") {\n responseMetadata.id = event.response.id;\n responseMetadata.model = event.response.model;\n return new ChatGenerationChunk({\n text: \"\",\n message: new AIMessageChunk({\n content: \"\",\n response_metadata: responseMetadata,\n }),\n });\n }\n\n if (event.type === \"response.completed\") {\n const aiMessage = convertResponseToAIMessage(event.response);\n return new ChatGenerationChunk({\n text: \"\",\n message: new AIMessageChunk({\n content: \"\",\n usage_metadata: aiMessage.usage_metadata,\n response_metadata: {\n ...responseMetadata,\n ...aiMessage.response_metadata,\n },\n }),\n });\n }\n\n return null;\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"responses.js","names":[],"sources":["../../src/converters/responses.ts"],"sourcesContent":["import {\n AIMessage,\n AIMessageChunk,\n BaseMessage,\n type UsageMetadata,\n} from \"@langchain/core/messages\";\nimport { ChatGenerationChunk } from \"@langchain/core/outputs\";\n\nimport type {\n XAIResponse,\n XAIResponsesInputItem,\n XAIResponsesMessage,\n XAIResponsesOutputContent,\n XAIResponsesOutputItem,\n XAIResponsesStreamEvent,\n XAIResponsesUsage,\n} from \"../chat_models/responses-types.js\";\n\n// ============================================================================\n// Message Converters\n// ============================================================================\n\n/**\n * Converts a single LangChain BaseMessage to xAI Responses API input format.\n *\n * @param message - The LangChain message to convert\n * @returns The xAI Responses API input item\n */\nexport function convertMessageToResponsesInput(\n message: BaseMessage\n): XAIResponsesInputItem {\n if (message.type === \"human\") {\n const content =\n typeof message.content === \"string\"\n ? message.content\n : message.content.map((part) => {\n if (typeof part === \"string\") {\n return { type: \"input_text\" as const, text: part };\n }\n if (part.type === \"text\") {\n return { type: \"input_text\" as const, text: part.text };\n }\n if (part.type === \"image_url\") {\n const imageUrlPart = part as {\n type: \"image_url\";\n image_url: string | { url: string };\n };\n const imageUrl =\n typeof imageUrlPart.image_url === \"string\"\n ? imageUrlPart.image_url\n : imageUrlPart.image_url.url;\n return {\n type: \"input_image\" as const,\n image_url: imageUrl,\n detail: \"auto\" as const,\n };\n }\n return { type: \"input_text\" as const, text: \"\" };\n });\n\n return {\n role: \"user\",\n content,\n } as XAIResponsesMessage;\n }\n\n if (message.type === \"system\") {\n return {\n role: \"system\",\n content:\n typeof message.content === \"string\"\n ? message.content\n : message.content\n .map((part) =>\n typeof part === \"string\" ? part : part.text || \"\"\n )\n .join(\"\"),\n } as XAIResponsesMessage;\n }\n\n if (message.type === \"ai\") {\n const aiMessage = message as AIMessage;\n return {\n type: \"message\",\n role: \"assistant\",\n text: typeof aiMessage.content === \"string\" ? aiMessage.content : \"\",\n } as unknown as XAIResponsesInputItem;\n }\n\n // Default fallback\n return {\n role: \"user\",\n content:\n typeof message.content === \"string\"\n ? message.content\n : JSON.stringify(message.content),\n } as XAIResponsesMessage;\n}\n\n/**\n * Converts an array of LangChain BaseMessages to xAI Responses API input format.\n *\n * @param messages - Array of LangChain messages to convert\n * @returns Array of xAI Responses API input items\n */\nexport function convertMessagesToResponsesInput(\n messages: BaseMessage[]\n): XAIResponsesInputItem[] {\n return messages.map(convertMessageToResponsesInput);\n}\n\n// ============================================================================\n// Usage Converters\n// ============================================================================\n\n/**\n * Converts xAI usage statistics to LangChain UsageMetadata format.\n *\n * @param usage - The xAI usage statistics\n * @returns LangChain UsageMetadata object\n */\nexport function convertUsageToUsageMetadata(\n usage: XAIResponsesUsage | null | undefined\n): UsageMetadata {\n return {\n input_tokens: usage?.input_tokens ?? 0,\n output_tokens: usage?.output_tokens ?? 0,\n total_tokens: usage?.total_tokens ?? 0,\n input_token_details: {\n ...(usage?.input_tokens_details?.cached_tokens != null && {\n cache_read: usage.input_tokens_details.cached_tokens,\n }),\n },\n output_token_details: {\n ...(usage?.output_tokens_details?.reasoning_tokens != null && {\n reasoning: usage.output_tokens_details.reasoning_tokens,\n }),\n },\n };\n}\n\n// ============================================================================\n// Output Converters\n// ============================================================================\n\n/**\n * Extracts text content from xAI response output items.\n *\n * @param output - Array of xAI response output items\n * @returns Concatenated text content\n */\nexport function extractTextFromOutput(\n output: XAIResponsesOutputItem[]\n): string {\n const textParts: string[] = [];\n\n for (const item of output) {\n if (item.type === \"message\" && \"content\" in item) {\n for (const contentItem of item.content as XAIResponsesOutputContent[]) {\n if (contentItem.type === \"output_text\") {\n textParts.push(contentItem.text);\n }\n }\n }\n }\n\n return textParts.join(\"\");\n}\n\n/**\n * Converts an xAI Response to a LangChain AIMessage.\n *\n * @param response - The xAI API response\n * @returns LangChain AIMessage\n */\nexport function convertResponseToAIMessage(response: XAIResponse): AIMessage {\n const text = extractTextFromOutput(response.output);\n\n const responseMetadata: Record<string, unknown> = {\n model_provider: \"xai\",\n model: response.model,\n created_at: response.created_at,\n id: response.id,\n status: response.status,\n object: response.object,\n };\n\n if (response.incomplete_details) {\n responseMetadata.incomplete_details = response.incomplete_details;\n }\n\n return new AIMessage({\n content: text,\n usage_metadata: convertUsageToUsageMetadata(response.usage),\n response_metadata: responseMetadata,\n additional_kwargs: {\n ...(response.reasoning && { reasoning: response.reasoning }),\n },\n });\n}\n\n// ============================================================================\n// Streaming Converters\n// ============================================================================\n\n/**\n * Converts an xAI streaming event to a LangChain ChatGenerationChunk.\n *\n * @param event - The xAI streaming event\n * @returns ChatGenerationChunk or null if the event doesn't produce a chunk\n */\nexport function convertStreamEventToChunk(\n event: XAIResponsesStreamEvent\n): ChatGenerationChunk | null {\n const responseMetadata: Record<string, unknown> = {\n model_provider: \"xai\",\n };\n\n if (event.type === \"response.output_text.delta\") {\n return new ChatGenerationChunk({\n text: event.delta,\n message: new AIMessageChunk({\n content: event.delta,\n response_metadata: responseMetadata,\n }),\n });\n }\n\n if (event.type === \"response.created\") {\n responseMetadata.id = event.response.id;\n responseMetadata.model = event.response.model;\n return new ChatGenerationChunk({\n text: \"\",\n message: new AIMessageChunk({\n content: \"\",\n response_metadata: responseMetadata,\n }),\n });\n }\n\n if (event.type === \"response.completed\") {\n const aiMessage = convertResponseToAIMessage(event.response);\n return new ChatGenerationChunk({\n text: \"\",\n message: new AIMessageChunk({\n content: \"\",\n usage_metadata: aiMessage.usage_metadata,\n response_metadata: {\n ...responseMetadata,\n ...aiMessage.response_metadata,\n },\n }),\n });\n }\n\n return null;\n}\n"],"mappings":"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"}
package/dist/index.cjs CHANGED
@@ -1,10 +1,9 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_completions = require('./chat_models/completions.cjs');
3
- const require_responses = require('./chat_models/responses.cjs');
4
- require('./chat_models/index.cjs');
5
- const require_index$1 = require('./tools/index.cjs');
6
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_completions = require("./chat_models/completions.cjs");
3
+ const require_responses = require("./chat_models/responses.cjs");
4
+ require("./chat_models/index.cjs");
5
+ const require_index$1 = require("./tools/index.cjs");
7
6
  exports.ChatXAI = require_completions.ChatXAI;
8
7
  exports.ChatXAIResponses = require_responses.ChatXAIResponses;
9
8
  exports.isXAIBuiltInTool = require_completions.isXAIBuiltInTool;
10
- exports.tools = require_index$1.tools;
9
+ exports.tools = require_index$1.tools;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { ChatXAI, ChatXAICallOptions, ChatXAICompletionsInvocationParams, ChatXAIInput, OpenAIToolChoice, XAIAdditionalKwargs, XAIBuiltInTool, XAIResponseMetadata, isXAIBuiltInTool } from "./chat_models/completions.js";
2
2
  import { ChatXAIResponsesCallOptions, ChatXAIResponsesInput, ChatXAIResponsesInvocationParams, XAIResponse, XAIResponsesAnnotation, XAIResponsesCodeInterpreterResult, XAIResponsesCodeInterpreterTool, XAIResponsesCodeInterpreterToolCall, XAIResponsesCreateParams, XAIResponsesCreateParamsNonStreaming, XAIResponsesCreateParamsStreaming, XAIResponsesDebugOutput, XAIResponsesFileCitationAnnotation, XAIResponsesFileSearchResult, XAIResponsesFileSearchTool, XAIResponsesFunctionTool, XAIResponsesFunctionToolCall, XAIResponsesFunctionToolFunction, XAIResponsesFunctionToolOutput, XAIResponsesInclude, XAIResponsesIncompleteDetails, XAIResponsesIncompleteReason, XAIResponsesInput, XAIResponsesInputContentItem, XAIResponsesInputFileItem, XAIResponsesInputImageItem, XAIResponsesInputItem, XAIResponsesInputTextItem, XAIResponsesLogprobContent, XAIResponsesLogprobToken, XAIResponsesLogprobs, XAIResponsesMcpTool, XAIResponsesMcpToolCall, XAIResponsesMessage, XAIResponsesMessageRole, XAIResponsesObjectType, XAIResponsesOutputCodeInterpreterCall, XAIResponsesOutputContent, XAIResponsesOutputFileSearchCall, XAIResponsesOutputFunctionCall, XAIResponsesOutputItem, XAIResponsesOutputMcpCall, XAIResponsesOutputReasoning, XAIResponsesOutputRefusalContent, XAIResponsesOutputTextContent, XAIResponsesOutputTextItem, XAIResponsesOutputWebSearchCall, XAIResponsesPreviousResponse, XAIResponsesReasoning, XAIResponsesReasoningEffort, XAIResponsesReasoningResponse, XAIResponsesReasoningSummary, XAIResponsesReasoningSummaryItem, XAIResponsesSearchMode, XAIResponsesSearchParameters, XAIResponsesSearchSource, XAIResponsesSearchSourceRss, XAIResponsesSearchSourceWeb, XAIResponsesSearchSourceX, XAIResponsesStatus, XAIResponsesStreamEvent, XAIResponsesStreamEventBase, XAIResponsesStreamEventCompleted, XAIResponsesStreamEventContentPartAdded, XAIResponsesStreamEventContentPartDone, XAIResponsesStreamEventCreated, XAIResponsesStreamEventError, XAIResponsesStreamEventFailed, XAIResponsesStreamEventFunctionCallArgumentsDelta, XAIResponsesStreamEventFunctionCallArgumentsDone, XAIResponsesStreamEventInProgress, XAIResponsesStreamEventIncomplete, XAIResponsesStreamEventOutputItemAdded, XAIResponsesStreamEventOutputItemDone, XAIResponsesStreamEventReasoningSummaryTextDelta, XAIResponsesStreamEventReasoningSummaryTextDone, XAIResponsesStreamEventTextDelta, XAIResponsesStreamEventTextDone, XAIResponsesText, XAIResponsesTextFormat, XAIResponsesTextFormatJsonObject, XAIResponsesTextFormatJsonSchema, XAIResponsesTextFormatText, XAIResponsesTool, XAIResponsesToolCall, XAIResponsesToolChoice, XAIResponsesToolChoiceFunction, XAIResponsesToolChoiceString, XAIResponsesToolOutput, XAIResponsesUrlCitationAnnotation, XAIResponsesUsage, XAIResponsesWebSearchTool, XAIResponsesWebSearchToolCall, XAIResponsesXSearchTool } from "./chat_models/responses-types.js";
3
3
  import { ChatXAIResponses } from "./chat_models/responses.js";
4
- import "./chat_models/index.js";
5
4
  import { tools } from "./tools/index.js";
6
5
  export { ChatXAI, ChatXAICallOptions, ChatXAICompletionsInvocationParams, ChatXAIInput, ChatXAIResponses, ChatXAIResponsesCallOptions, ChatXAIResponsesInput, ChatXAIResponsesInvocationParams, OpenAIToolChoice, XAIAdditionalKwargs, XAIBuiltInTool, XAIResponse, XAIResponseMetadata, XAIResponsesAnnotation, XAIResponsesCodeInterpreterResult, XAIResponsesCodeInterpreterTool, XAIResponsesCodeInterpreterToolCall, XAIResponsesCreateParams, XAIResponsesCreateParamsNonStreaming, XAIResponsesCreateParamsStreaming, XAIResponsesDebugOutput, XAIResponsesFileCitationAnnotation, XAIResponsesFileSearchResult, XAIResponsesFileSearchTool, XAIResponsesFunctionTool, XAIResponsesFunctionToolCall, XAIResponsesFunctionToolFunction, XAIResponsesFunctionToolOutput, XAIResponsesInclude, XAIResponsesIncompleteDetails, XAIResponsesIncompleteReason, XAIResponsesInput, XAIResponsesInputContentItem, XAIResponsesInputFileItem, XAIResponsesInputImageItem, XAIResponsesInputItem, XAIResponsesInputTextItem, XAIResponsesLogprobContent, XAIResponsesLogprobToken, XAIResponsesLogprobs, XAIResponsesMcpTool, XAIResponsesMcpToolCall, XAIResponsesMessage, XAIResponsesMessageRole, XAIResponsesObjectType, XAIResponsesOutputCodeInterpreterCall, XAIResponsesOutputContent, XAIResponsesOutputFileSearchCall, XAIResponsesOutputFunctionCall, XAIResponsesOutputItem, XAIResponsesOutputMcpCall, XAIResponsesOutputReasoning, XAIResponsesOutputRefusalContent, XAIResponsesOutputTextContent, XAIResponsesOutputTextItem, XAIResponsesOutputWebSearchCall, XAIResponsesPreviousResponse, XAIResponsesReasoning, XAIResponsesReasoningEffort, XAIResponsesReasoningResponse, XAIResponsesReasoningSummary, XAIResponsesReasoningSummaryItem, XAIResponsesSearchMode, XAIResponsesSearchParameters, XAIResponsesSearchSource, XAIResponsesSearchSourceRss, XAIResponsesSearchSourceWeb, XAIResponsesSearchSourceX, XAIResponsesStatus, XAIResponsesStreamEvent, XAIResponsesStreamEventBase, XAIResponsesStreamEventCompleted, XAIResponsesStreamEventContentPartAdded, XAIResponsesStreamEventContentPartDone, XAIResponsesStreamEventCreated, XAIResponsesStreamEventError, XAIResponsesStreamEventFailed, XAIResponsesStreamEventFunctionCallArgumentsDelta, XAIResponsesStreamEventFunctionCallArgumentsDone, XAIResponsesStreamEventInProgress, XAIResponsesStreamEventIncomplete, XAIResponsesStreamEventOutputItemAdded, XAIResponsesStreamEventOutputItemDone, XAIResponsesStreamEventReasoningSummaryTextDelta, XAIResponsesStreamEventReasoningSummaryTextDone, XAIResponsesStreamEventTextDelta, XAIResponsesStreamEventTextDone, XAIResponsesText, XAIResponsesTextFormat, XAIResponsesTextFormatJsonObject, XAIResponsesTextFormatJsonSchema, XAIResponsesTextFormatText, XAIResponsesTool, XAIResponsesToolCall, XAIResponsesToolChoice, XAIResponsesToolChoiceFunction, XAIResponsesToolChoiceString, XAIResponsesToolOutput, XAIResponsesUrlCitationAnnotation, XAIResponsesUsage, XAIResponsesWebSearchTool, XAIResponsesWebSearchToolCall, XAIResponsesXSearchTool, isXAIBuiltInTool, tools };
package/dist/index.js CHANGED
@@ -2,5 +2,4 @@ import { ChatXAI, isXAIBuiltInTool } from "./chat_models/completions.js";
2
2
  import { ChatXAIResponses } from "./chat_models/responses.js";
3
3
  import "./chat_models/index.js";
4
4
  import { tools } from "./tools/index.js";
5
-
6
- export { ChatXAI, ChatXAIResponses, isXAIBuiltInTool, tools };
5
+ export { ChatXAI, ChatXAIResponses, isXAIBuiltInTool, tools };
@@ -1,4 +1,3 @@
1
-
2
1
  //#region src/live_search.ts
3
2
  /**
4
3
  * Merge search parameters from instance defaults, tool definition
@@ -46,9 +45,9 @@ function filterXAIBuiltInTools(payload) {
46
45
  });
47
46
  return filtered.length > 0 ? filtered : void 0;
48
47
  }
49
-
50
48
  //#endregion
51
49
  exports.buildSearchParametersPayload = buildSearchParametersPayload;
52
50
  exports.filterXAIBuiltInTools = filterXAIBuiltInTools;
53
51
  exports.mergeSearchParams = mergeSearchParams;
52
+
54
53
  //# sourceMappingURL=live_search.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"live_search.cjs","names":[],"sources":["../src/live_search.ts"],"sourcesContent":["/**\n * Web search source configuration for xAI Live Search.\n * Corresponds to a `{\"type\": \"web\", ...}` entry in `search_parameters.sources`.\n */\nexport interface XAIWebSource {\n type: \"web\";\n /**\n * Optional ISO alpha-2 country code used to bias results\n * towards a specific country/region.\n */\n country?: string;\n /**\n * Websites that should be excluded from the search results.\n * Maximum of 5 entries.\n */\n excluded_websites?: string[];\n /**\n * Websites that should be exclusively included in the search results.\n * Maximum of 5 entries.\n */\n allowed_websites?: string[];\n /**\n * Whether to enable safe search filtering for this source.\n */\n safe_search?: boolean;\n}\n\n/**\n * News search source configuration for xAI Live Search.\n * Corresponds to a `{\"type\": \"news\", ...}` entry in `search_parameters.sources`.\n */\nexport interface XAINewsSource {\n type: \"news\";\n /**\n * Optional ISO alpha-2 country code used to bias results\n * towards a specific country/region.\n */\n country?: string;\n /**\n * Websites that should be excluded from the search results.\n * Maximum of 5 entries.\n */\n excluded_websites?: string[];\n /**\n * Whether to enable safe search filtering for this source.\n */\n safe_search?: boolean;\n}\n\n/**\n * X (formerly Twitter) search source configuration for xAI Live Search.\n * Corresponds to a `{\"type\": \"x\", ...}` entry in `search_parameters.sources`.\n */\nexport interface XAIXSource {\n type: \"x\";\n /**\n * X handles that should be explicitly included in the search.\n * Maximum of 10 entries.\n */\n included_x_handles?: string[];\n /**\n * X handles that should be excluded from the search.\n * Maximum of 10 entries.\n */\n excluded_x_handles?: string[];\n /**\n * Minimum number of favorites a post must have to be included.\n */\n post_favorite_count?: number;\n /**\n * Minimum number of views a post must have to be included.\n */\n post_view_count?: number;\n}\n\n/**\n * RSS feed search source configuration for xAI Live Search.\n * Corresponds to a `{\"type\": \"rss\", ...}` entry in `search_parameters.sources`.\n */\nexport interface XAIRssSource {\n type: \"rss\";\n /**\n * Links to RSS feeds to be used as a data source.\n * The API currently expects a single URL.\n */\n links: string[];\n}\n\nexport type XAISearchSource =\n | XAIWebSource\n | XAINewsSource\n | XAIXSource\n | XAIRssSource;\n\n/**\n * Search parameters for xAI's Live Search API.\n * Controls how the model searches for and retrieves real-time information.\n *\n * @note The Live Search API is being deprecated by xAI in favor of\n * the agentic tool calling approach. Consider using `tools: [{ type: \"live_search\" }]`\n * for future compatibility.\n */\nexport interface XAISearchParameters {\n /**\n * Controls when the model should perform a search.\n * - \"auto\": Let the model decide when to search (default)\n * - \"on\": Always search for every request\n * - \"off\": Never search\n */\n mode?: \"auto\" | \"on\" | \"off\";\n /**\n * Maximum number of search results to return.\n * @default 20\n */\n max_search_results?: number;\n /**\n * Filter search results to only include content from after this date.\n * Format: ISO 8601 date string (e.g., \"2024-01-01\")\n */\n from_date?: string;\n /**\n * Filter search results to only include content from before this date.\n * Format: ISO 8601 date string (e.g., \"2024-12-31\")\n */\n to_date?: string;\n /**\n * Whether to return citations/sources for the search results.\n * @default true\n */\n return_citations?: boolean;\n /**\n * Specific web/news/X/RSS sources that can be used for the search.\n * Each entry corresponds to a `{\"type\": \"...\", ...}` object in\n * `search_parameters.sources` as documented in the xAI Live Search docs.\n *\n * If omitted, xAI will default to enabling `web`, `news` and `x` sources.\n */\n sources?: XAISearchSource[];\n}\n\n/**\n * Concrete payload shape sent as `search_parameters` to the xAI API.\n */\nexport interface XAISearchParametersPayload {\n mode: \"auto\" | \"on\" | \"off\";\n max_search_results?: number;\n from_date?: string;\n to_date?: string;\n return_citations?: boolean;\n sources?: XAISearchSource[];\n}\n\n/**\n * Merge search parameters from instance defaults, tool definition\n * and per-call overrides.\n *\n * Precedence (lowest → highest):\n * 1. tool-level configuration (e.g. from xaiLiveSearch)\n * 2. instance-level defaults\n * 3. per-call overrides passed via `searchParameters`\n */\nexport function mergeSearchParams(\n instanceParams?: XAISearchParameters,\n callParams?: XAISearchParameters,\n toolParams?: XAISearchParameters\n): XAISearchParameters | undefined {\n if (!instanceParams && !callParams && !toolParams) {\n return undefined;\n }\n\n return {\n ...(toolParams ?? {}),\n ...(instanceParams ?? {}),\n ...(callParams ?? {}),\n };\n}\n\n/**\n * Build the `search_parameters` payload to send to the xAI API\n * from high-level `XAISearchParameters`.\n */\nexport function buildSearchParametersPayload(\n params?: XAISearchParameters\n): XAISearchParametersPayload | undefined {\n if (!params) {\n return undefined;\n }\n\n const payload: XAISearchParametersPayload = {\n mode: params.mode ?? \"auto\",\n };\n\n if (params.max_search_results !== undefined) {\n payload.max_search_results = params.max_search_results;\n }\n if (params.from_date !== undefined) {\n payload.from_date = params.from_date;\n }\n if (params.to_date !== undefined) {\n payload.to_date = params.to_date;\n }\n if (params.return_citations !== undefined) {\n payload.return_citations = params.return_citations;\n }\n if (params.sources && params.sources.length > 0) {\n payload.sources = params.sources;\n }\n\n return payload;\n}\n\n/**\n * Filter out xAI built-in tools (like `live_search`) from a tools array.\n * Used before sending the request to the xAI API, since built-in tools\n * are controlled via `search_parameters` instead.\n */\nexport function filterXAIBuiltInTools<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends { [key: string]: any },\n>(payload?: { tools?: T[]; excludedTypes?: string[] }): T[] | undefined {\n if (!payload?.tools) {\n return undefined;\n }\n\n const filtered = payload.tools.filter((tool) => {\n if (tool == null || typeof tool !== \"object\") {\n return true;\n }\n\n if (!(\"type\" in tool)) {\n return true;\n }\n\n if (!payload?.excludedTypes?.length) {\n return true;\n }\n\n return !payload.excludedTypes.includes(tool.type);\n });\n\n return filtered.length > 0 ? filtered : undefined;\n}\n"],"mappings":";;;;;;;;;;;AAiKA,SAAgB,kBACd,gBACA,YACA,YACiC;AACjC,KAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,WACrC;AAGF,QAAO;EACL,GAAI,cAAc,EAAE;EACpB,GAAI,kBAAkB,EAAE;EACxB,GAAI,cAAc,EAAE;EACrB;;;;;;AAOH,SAAgB,6BACd,QACwC;AACxC,KAAI,CAAC,OACH;CAGF,MAAM,UAAsC,EAC1C,MAAM,OAAO,QAAQ,QACtB;AAED,KAAI,OAAO,uBAAuB,OAChC,SAAQ,qBAAqB,OAAO;AAEtC,KAAI,OAAO,cAAc,OACvB,SAAQ,YAAY,OAAO;AAE7B,KAAI,OAAO,YAAY,OACrB,SAAQ,UAAU,OAAO;AAE3B,KAAI,OAAO,qBAAqB,OAC9B,SAAQ,mBAAmB,OAAO;AAEpC,KAAI,OAAO,WAAW,OAAO,QAAQ,SAAS,EAC5C,SAAQ,UAAU,OAAO;AAG3B,QAAO;;;;;;;AAQT,SAAgB,sBAGd,SAAsE;AACtE,KAAI,CAAC,SAAS,MACZ;CAGF,MAAM,WAAW,QAAQ,MAAM,QAAQ,SAAS;AAC9C,MAAI,QAAQ,QAAQ,OAAO,SAAS,SAClC,QAAO;AAGT,MAAI,EAAE,UAAU,MACd,QAAO;AAGT,MAAI,CAAC,SAAS,eAAe,OAC3B,QAAO;AAGT,SAAO,CAAC,QAAQ,cAAc,SAAS,KAAK,KAAK;GACjD;AAEF,QAAO,SAAS,SAAS,IAAI,WAAW"}
1
+ {"version":3,"file":"live_search.cjs","names":[],"sources":["../src/live_search.ts"],"sourcesContent":["/**\n * Web search source configuration for xAI Live Search.\n * Corresponds to a `{\"type\": \"web\", ...}` entry in `search_parameters.sources`.\n */\nexport interface XAIWebSource {\n type: \"web\";\n /**\n * Optional ISO alpha-2 country code used to bias results\n * towards a specific country/region.\n */\n country?: string;\n /**\n * Websites that should be excluded from the search results.\n * Maximum of 5 entries.\n */\n excluded_websites?: string[];\n /**\n * Websites that should be exclusively included in the search results.\n * Maximum of 5 entries.\n */\n allowed_websites?: string[];\n /**\n * Whether to enable safe search filtering for this source.\n */\n safe_search?: boolean;\n}\n\n/**\n * News search source configuration for xAI Live Search.\n * Corresponds to a `{\"type\": \"news\", ...}` entry in `search_parameters.sources`.\n */\nexport interface XAINewsSource {\n type: \"news\";\n /**\n * Optional ISO alpha-2 country code used to bias results\n * towards a specific country/region.\n */\n country?: string;\n /**\n * Websites that should be excluded from the search results.\n * Maximum of 5 entries.\n */\n excluded_websites?: string[];\n /**\n * Whether to enable safe search filtering for this source.\n */\n safe_search?: boolean;\n}\n\n/**\n * X (formerly Twitter) search source configuration for xAI Live Search.\n * Corresponds to a `{\"type\": \"x\", ...}` entry in `search_parameters.sources`.\n */\nexport interface XAIXSource {\n type: \"x\";\n /**\n * X handles that should be explicitly included in the search.\n * Maximum of 10 entries.\n */\n included_x_handles?: string[];\n /**\n * X handles that should be excluded from the search.\n * Maximum of 10 entries.\n */\n excluded_x_handles?: string[];\n /**\n * Minimum number of favorites a post must have to be included.\n */\n post_favorite_count?: number;\n /**\n * Minimum number of views a post must have to be included.\n */\n post_view_count?: number;\n}\n\n/**\n * RSS feed search source configuration for xAI Live Search.\n * Corresponds to a `{\"type\": \"rss\", ...}` entry in `search_parameters.sources`.\n */\nexport interface XAIRssSource {\n type: \"rss\";\n /**\n * Links to RSS feeds to be used as a data source.\n * The API currently expects a single URL.\n */\n links: string[];\n}\n\nexport type XAISearchSource =\n | XAIWebSource\n | XAINewsSource\n | XAIXSource\n | XAIRssSource;\n\n/**\n * Search parameters for xAI's Live Search API.\n * Controls how the model searches for and retrieves real-time information.\n *\n * @note The Live Search API is being deprecated by xAI in favor of\n * the agentic tool calling approach. Consider using `tools: [{ type: \"live_search\" }]`\n * for future compatibility.\n */\nexport interface XAISearchParameters {\n /**\n * Controls when the model should perform a search.\n * - \"auto\": Let the model decide when to search (default)\n * - \"on\": Always search for every request\n * - \"off\": Never search\n */\n mode?: \"auto\" | \"on\" | \"off\";\n /**\n * Maximum number of search results to return.\n * @default 20\n */\n max_search_results?: number;\n /**\n * Filter search results to only include content from after this date.\n * Format: ISO 8601 date string (e.g., \"2024-01-01\")\n */\n from_date?: string;\n /**\n * Filter search results to only include content from before this date.\n * Format: ISO 8601 date string (e.g., \"2024-12-31\")\n */\n to_date?: string;\n /**\n * Whether to return citations/sources for the search results.\n * @default true\n */\n return_citations?: boolean;\n /**\n * Specific web/news/X/RSS sources that can be used for the search.\n * Each entry corresponds to a `{\"type\": \"...\", ...}` object in\n * `search_parameters.sources` as documented in the xAI Live Search docs.\n *\n * If omitted, xAI will default to enabling `web`, `news` and `x` sources.\n */\n sources?: XAISearchSource[];\n}\n\n/**\n * Concrete payload shape sent as `search_parameters` to the xAI API.\n */\nexport interface XAISearchParametersPayload {\n mode: \"auto\" | \"on\" | \"off\";\n max_search_results?: number;\n from_date?: string;\n to_date?: string;\n return_citations?: boolean;\n sources?: XAISearchSource[];\n}\n\n/**\n * Merge search parameters from instance defaults, tool definition\n * and per-call overrides.\n *\n * Precedence (lowest → highest):\n * 1. tool-level configuration (e.g. from xaiLiveSearch)\n * 2. instance-level defaults\n * 3. per-call overrides passed via `searchParameters`\n */\nexport function mergeSearchParams(\n instanceParams?: XAISearchParameters,\n callParams?: XAISearchParameters,\n toolParams?: XAISearchParameters\n): XAISearchParameters | undefined {\n if (!instanceParams && !callParams && !toolParams) {\n return undefined;\n }\n\n return {\n ...(toolParams ?? {}),\n ...(instanceParams ?? {}),\n ...(callParams ?? {}),\n };\n}\n\n/**\n * Build the `search_parameters` payload to send to the xAI API\n * from high-level `XAISearchParameters`.\n */\nexport function buildSearchParametersPayload(\n params?: XAISearchParameters\n): XAISearchParametersPayload | undefined {\n if (!params) {\n return undefined;\n }\n\n const payload: XAISearchParametersPayload = {\n mode: params.mode ?? \"auto\",\n };\n\n if (params.max_search_results !== undefined) {\n payload.max_search_results = params.max_search_results;\n }\n if (params.from_date !== undefined) {\n payload.from_date = params.from_date;\n }\n if (params.to_date !== undefined) {\n payload.to_date = params.to_date;\n }\n if (params.return_citations !== undefined) {\n payload.return_citations = params.return_citations;\n }\n if (params.sources && params.sources.length > 0) {\n payload.sources = params.sources;\n }\n\n return payload;\n}\n\n/**\n * Filter out xAI built-in tools (like `live_search`) from a tools array.\n * Used before sending the request to the xAI API, since built-in tools\n * are controlled via `search_parameters` instead.\n */\nexport function filterXAIBuiltInTools<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends { [key: string]: any },\n>(payload?: { tools?: T[]; excludedTypes?: string[] }): T[] | undefined {\n if (!payload?.tools) {\n return undefined;\n }\n\n const filtered = payload.tools.filter((tool) => {\n if (tool == null || typeof tool !== \"object\") {\n return true;\n }\n\n if (!(\"type\" in tool)) {\n return true;\n }\n\n if (!payload?.excludedTypes?.length) {\n return true;\n }\n\n return !payload.excludedTypes.includes(tool.type);\n });\n\n return filtered.length > 0 ? filtered : undefined;\n}\n"],"mappings":";;;;;;;;;;AAiKA,SAAgB,kBACd,gBACA,YACA,YACiC;AACjC,KAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,WACrC;AAGF,QAAO;EACL,GAAI,cAAc,EAAE;EACpB,GAAI,kBAAkB,EAAE;EACxB,GAAI,cAAc,EAAE;EACrB;;;;;;AAOH,SAAgB,6BACd,QACwC;AACxC,KAAI,CAAC,OACH;CAGF,MAAM,UAAsC,EAC1C,MAAM,OAAO,QAAQ,QACtB;AAED,KAAI,OAAO,uBAAuB,KAAA,EAChC,SAAQ,qBAAqB,OAAO;AAEtC,KAAI,OAAO,cAAc,KAAA,EACvB,SAAQ,YAAY,OAAO;AAE7B,KAAI,OAAO,YAAY,KAAA,EACrB,SAAQ,UAAU,OAAO;AAE3B,KAAI,OAAO,qBAAqB,KAAA,EAC9B,SAAQ,mBAAmB,OAAO;AAEpC,KAAI,OAAO,WAAW,OAAO,QAAQ,SAAS,EAC5C,SAAQ,UAAU,OAAO;AAG3B,QAAO;;;;;;;AAQT,SAAgB,sBAGd,SAAsE;AACtE,KAAI,CAAC,SAAS,MACZ;CAGF,MAAM,WAAW,QAAQ,MAAM,QAAQ,SAAS;AAC9C,MAAI,QAAQ,QAAQ,OAAO,SAAS,SAClC,QAAO;AAGT,MAAI,EAAE,UAAU,MACd,QAAO;AAGT,MAAI,CAAC,SAAS,eAAe,OAC3B,QAAO;AAGT,SAAO,CAAC,QAAQ,cAAc,SAAS,KAAK,KAAK;GACjD;AAEF,QAAO,SAAS,SAAS,IAAI,WAAW,KAAA"}
@@ -45,7 +45,7 @@ function filterXAIBuiltInTools(payload) {
45
45
  });
46
46
  return filtered.length > 0 ? filtered : void 0;
47
47
  }
48
-
49
48
  //#endregion
50
49
  export { buildSearchParametersPayload, filterXAIBuiltInTools, mergeSearchParams };
50
+
51
51
  //# sourceMappingURL=live_search.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"live_search.js","names":[],"sources":["../src/live_search.ts"],"sourcesContent":["/**\n * Web search source configuration for xAI Live Search.\n * Corresponds to a `{\"type\": \"web\", ...}` entry in `search_parameters.sources`.\n */\nexport interface XAIWebSource {\n type: \"web\";\n /**\n * Optional ISO alpha-2 country code used to bias results\n * towards a specific country/region.\n */\n country?: string;\n /**\n * Websites that should be excluded from the search results.\n * Maximum of 5 entries.\n */\n excluded_websites?: string[];\n /**\n * Websites that should be exclusively included in the search results.\n * Maximum of 5 entries.\n */\n allowed_websites?: string[];\n /**\n * Whether to enable safe search filtering for this source.\n */\n safe_search?: boolean;\n}\n\n/**\n * News search source configuration for xAI Live Search.\n * Corresponds to a `{\"type\": \"news\", ...}` entry in `search_parameters.sources`.\n */\nexport interface XAINewsSource {\n type: \"news\";\n /**\n * Optional ISO alpha-2 country code used to bias results\n * towards a specific country/region.\n */\n country?: string;\n /**\n * Websites that should be excluded from the search results.\n * Maximum of 5 entries.\n */\n excluded_websites?: string[];\n /**\n * Whether to enable safe search filtering for this source.\n */\n safe_search?: boolean;\n}\n\n/**\n * X (formerly Twitter) search source configuration for xAI Live Search.\n * Corresponds to a `{\"type\": \"x\", ...}` entry in `search_parameters.sources`.\n */\nexport interface XAIXSource {\n type: \"x\";\n /**\n * X handles that should be explicitly included in the search.\n * Maximum of 10 entries.\n */\n included_x_handles?: string[];\n /**\n * X handles that should be excluded from the search.\n * Maximum of 10 entries.\n */\n excluded_x_handles?: string[];\n /**\n * Minimum number of favorites a post must have to be included.\n */\n post_favorite_count?: number;\n /**\n * Minimum number of views a post must have to be included.\n */\n post_view_count?: number;\n}\n\n/**\n * RSS feed search source configuration for xAI Live Search.\n * Corresponds to a `{\"type\": \"rss\", ...}` entry in `search_parameters.sources`.\n */\nexport interface XAIRssSource {\n type: \"rss\";\n /**\n * Links to RSS feeds to be used as a data source.\n * The API currently expects a single URL.\n */\n links: string[];\n}\n\nexport type XAISearchSource =\n | XAIWebSource\n | XAINewsSource\n | XAIXSource\n | XAIRssSource;\n\n/**\n * Search parameters for xAI's Live Search API.\n * Controls how the model searches for and retrieves real-time information.\n *\n * @note The Live Search API is being deprecated by xAI in favor of\n * the agentic tool calling approach. Consider using `tools: [{ type: \"live_search\" }]`\n * for future compatibility.\n */\nexport interface XAISearchParameters {\n /**\n * Controls when the model should perform a search.\n * - \"auto\": Let the model decide when to search (default)\n * - \"on\": Always search for every request\n * - \"off\": Never search\n */\n mode?: \"auto\" | \"on\" | \"off\";\n /**\n * Maximum number of search results to return.\n * @default 20\n */\n max_search_results?: number;\n /**\n * Filter search results to only include content from after this date.\n * Format: ISO 8601 date string (e.g., \"2024-01-01\")\n */\n from_date?: string;\n /**\n * Filter search results to only include content from before this date.\n * Format: ISO 8601 date string (e.g., \"2024-12-31\")\n */\n to_date?: string;\n /**\n * Whether to return citations/sources for the search results.\n * @default true\n */\n return_citations?: boolean;\n /**\n * Specific web/news/X/RSS sources that can be used for the search.\n * Each entry corresponds to a `{\"type\": \"...\", ...}` object in\n * `search_parameters.sources` as documented in the xAI Live Search docs.\n *\n * If omitted, xAI will default to enabling `web`, `news` and `x` sources.\n */\n sources?: XAISearchSource[];\n}\n\n/**\n * Concrete payload shape sent as `search_parameters` to the xAI API.\n */\nexport interface XAISearchParametersPayload {\n mode: \"auto\" | \"on\" | \"off\";\n max_search_results?: number;\n from_date?: string;\n to_date?: string;\n return_citations?: boolean;\n sources?: XAISearchSource[];\n}\n\n/**\n * Merge search parameters from instance defaults, tool definition\n * and per-call overrides.\n *\n * Precedence (lowest → highest):\n * 1. tool-level configuration (e.g. from xaiLiveSearch)\n * 2. instance-level defaults\n * 3. per-call overrides passed via `searchParameters`\n */\nexport function mergeSearchParams(\n instanceParams?: XAISearchParameters,\n callParams?: XAISearchParameters,\n toolParams?: XAISearchParameters\n): XAISearchParameters | undefined {\n if (!instanceParams && !callParams && !toolParams) {\n return undefined;\n }\n\n return {\n ...(toolParams ?? {}),\n ...(instanceParams ?? {}),\n ...(callParams ?? {}),\n };\n}\n\n/**\n * Build the `search_parameters` payload to send to the xAI API\n * from high-level `XAISearchParameters`.\n */\nexport function buildSearchParametersPayload(\n params?: XAISearchParameters\n): XAISearchParametersPayload | undefined {\n if (!params) {\n return undefined;\n }\n\n const payload: XAISearchParametersPayload = {\n mode: params.mode ?? \"auto\",\n };\n\n if (params.max_search_results !== undefined) {\n payload.max_search_results = params.max_search_results;\n }\n if (params.from_date !== undefined) {\n payload.from_date = params.from_date;\n }\n if (params.to_date !== undefined) {\n payload.to_date = params.to_date;\n }\n if (params.return_citations !== undefined) {\n payload.return_citations = params.return_citations;\n }\n if (params.sources && params.sources.length > 0) {\n payload.sources = params.sources;\n }\n\n return payload;\n}\n\n/**\n * Filter out xAI built-in tools (like `live_search`) from a tools array.\n * Used before sending the request to the xAI API, since built-in tools\n * are controlled via `search_parameters` instead.\n */\nexport function filterXAIBuiltInTools<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends { [key: string]: any },\n>(payload?: { tools?: T[]; excludedTypes?: string[] }): T[] | undefined {\n if (!payload?.tools) {\n return undefined;\n }\n\n const filtered = payload.tools.filter((tool) => {\n if (tool == null || typeof tool !== \"object\") {\n return true;\n }\n\n if (!(\"type\" in tool)) {\n return true;\n }\n\n if (!payload?.excludedTypes?.length) {\n return true;\n }\n\n return !payload.excludedTypes.includes(tool.type);\n });\n\n return filtered.length > 0 ? filtered : undefined;\n}\n"],"mappings":";;;;;;;;;;AAiKA,SAAgB,kBACd,gBACA,YACA,YACiC;AACjC,KAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,WACrC;AAGF,QAAO;EACL,GAAI,cAAc,EAAE;EACpB,GAAI,kBAAkB,EAAE;EACxB,GAAI,cAAc,EAAE;EACrB;;;;;;AAOH,SAAgB,6BACd,QACwC;AACxC,KAAI,CAAC,OACH;CAGF,MAAM,UAAsC,EAC1C,MAAM,OAAO,QAAQ,QACtB;AAED,KAAI,OAAO,uBAAuB,OAChC,SAAQ,qBAAqB,OAAO;AAEtC,KAAI,OAAO,cAAc,OACvB,SAAQ,YAAY,OAAO;AAE7B,KAAI,OAAO,YAAY,OACrB,SAAQ,UAAU,OAAO;AAE3B,KAAI,OAAO,qBAAqB,OAC9B,SAAQ,mBAAmB,OAAO;AAEpC,KAAI,OAAO,WAAW,OAAO,QAAQ,SAAS,EAC5C,SAAQ,UAAU,OAAO;AAG3B,QAAO;;;;;;;AAQT,SAAgB,sBAGd,SAAsE;AACtE,KAAI,CAAC,SAAS,MACZ;CAGF,MAAM,WAAW,QAAQ,MAAM,QAAQ,SAAS;AAC9C,MAAI,QAAQ,QAAQ,OAAO,SAAS,SAClC,QAAO;AAGT,MAAI,EAAE,UAAU,MACd,QAAO;AAGT,MAAI,CAAC,SAAS,eAAe,OAC3B,QAAO;AAGT,SAAO,CAAC,QAAQ,cAAc,SAAS,KAAK,KAAK;GACjD;AAEF,QAAO,SAAS,SAAS,IAAI,WAAW"}
1
+ {"version":3,"file":"live_search.js","names":[],"sources":["../src/live_search.ts"],"sourcesContent":["/**\n * Web search source configuration for xAI Live Search.\n * Corresponds to a `{\"type\": \"web\", ...}` entry in `search_parameters.sources`.\n */\nexport interface XAIWebSource {\n type: \"web\";\n /**\n * Optional ISO alpha-2 country code used to bias results\n * towards a specific country/region.\n */\n country?: string;\n /**\n * Websites that should be excluded from the search results.\n * Maximum of 5 entries.\n */\n excluded_websites?: string[];\n /**\n * Websites that should be exclusively included in the search results.\n * Maximum of 5 entries.\n */\n allowed_websites?: string[];\n /**\n * Whether to enable safe search filtering for this source.\n */\n safe_search?: boolean;\n}\n\n/**\n * News search source configuration for xAI Live Search.\n * Corresponds to a `{\"type\": \"news\", ...}` entry in `search_parameters.sources`.\n */\nexport interface XAINewsSource {\n type: \"news\";\n /**\n * Optional ISO alpha-2 country code used to bias results\n * towards a specific country/region.\n */\n country?: string;\n /**\n * Websites that should be excluded from the search results.\n * Maximum of 5 entries.\n */\n excluded_websites?: string[];\n /**\n * Whether to enable safe search filtering for this source.\n */\n safe_search?: boolean;\n}\n\n/**\n * X (formerly Twitter) search source configuration for xAI Live Search.\n * Corresponds to a `{\"type\": \"x\", ...}` entry in `search_parameters.sources`.\n */\nexport interface XAIXSource {\n type: \"x\";\n /**\n * X handles that should be explicitly included in the search.\n * Maximum of 10 entries.\n */\n included_x_handles?: string[];\n /**\n * X handles that should be excluded from the search.\n * Maximum of 10 entries.\n */\n excluded_x_handles?: string[];\n /**\n * Minimum number of favorites a post must have to be included.\n */\n post_favorite_count?: number;\n /**\n * Minimum number of views a post must have to be included.\n */\n post_view_count?: number;\n}\n\n/**\n * RSS feed search source configuration for xAI Live Search.\n * Corresponds to a `{\"type\": \"rss\", ...}` entry in `search_parameters.sources`.\n */\nexport interface XAIRssSource {\n type: \"rss\";\n /**\n * Links to RSS feeds to be used as a data source.\n * The API currently expects a single URL.\n */\n links: string[];\n}\n\nexport type XAISearchSource =\n | XAIWebSource\n | XAINewsSource\n | XAIXSource\n | XAIRssSource;\n\n/**\n * Search parameters for xAI's Live Search API.\n * Controls how the model searches for and retrieves real-time information.\n *\n * @note The Live Search API is being deprecated by xAI in favor of\n * the agentic tool calling approach. Consider using `tools: [{ type: \"live_search\" }]`\n * for future compatibility.\n */\nexport interface XAISearchParameters {\n /**\n * Controls when the model should perform a search.\n * - \"auto\": Let the model decide when to search (default)\n * - \"on\": Always search for every request\n * - \"off\": Never search\n */\n mode?: \"auto\" | \"on\" | \"off\";\n /**\n * Maximum number of search results to return.\n * @default 20\n */\n max_search_results?: number;\n /**\n * Filter search results to only include content from after this date.\n * Format: ISO 8601 date string (e.g., \"2024-01-01\")\n */\n from_date?: string;\n /**\n * Filter search results to only include content from before this date.\n * Format: ISO 8601 date string (e.g., \"2024-12-31\")\n */\n to_date?: string;\n /**\n * Whether to return citations/sources for the search results.\n * @default true\n */\n return_citations?: boolean;\n /**\n * Specific web/news/X/RSS sources that can be used for the search.\n * Each entry corresponds to a `{\"type\": \"...\", ...}` object in\n * `search_parameters.sources` as documented in the xAI Live Search docs.\n *\n * If omitted, xAI will default to enabling `web`, `news` and `x` sources.\n */\n sources?: XAISearchSource[];\n}\n\n/**\n * Concrete payload shape sent as `search_parameters` to the xAI API.\n */\nexport interface XAISearchParametersPayload {\n mode: \"auto\" | \"on\" | \"off\";\n max_search_results?: number;\n from_date?: string;\n to_date?: string;\n return_citations?: boolean;\n sources?: XAISearchSource[];\n}\n\n/**\n * Merge search parameters from instance defaults, tool definition\n * and per-call overrides.\n *\n * Precedence (lowest → highest):\n * 1. tool-level configuration (e.g. from xaiLiveSearch)\n * 2. instance-level defaults\n * 3. per-call overrides passed via `searchParameters`\n */\nexport function mergeSearchParams(\n instanceParams?: XAISearchParameters,\n callParams?: XAISearchParameters,\n toolParams?: XAISearchParameters\n): XAISearchParameters | undefined {\n if (!instanceParams && !callParams && !toolParams) {\n return undefined;\n }\n\n return {\n ...(toolParams ?? {}),\n ...(instanceParams ?? {}),\n ...(callParams ?? {}),\n };\n}\n\n/**\n * Build the `search_parameters` payload to send to the xAI API\n * from high-level `XAISearchParameters`.\n */\nexport function buildSearchParametersPayload(\n params?: XAISearchParameters\n): XAISearchParametersPayload | undefined {\n if (!params) {\n return undefined;\n }\n\n const payload: XAISearchParametersPayload = {\n mode: params.mode ?? \"auto\",\n };\n\n if (params.max_search_results !== undefined) {\n payload.max_search_results = params.max_search_results;\n }\n if (params.from_date !== undefined) {\n payload.from_date = params.from_date;\n }\n if (params.to_date !== undefined) {\n payload.to_date = params.to_date;\n }\n if (params.return_citations !== undefined) {\n payload.return_citations = params.return_citations;\n }\n if (params.sources && params.sources.length > 0) {\n payload.sources = params.sources;\n }\n\n return payload;\n}\n\n/**\n * Filter out xAI built-in tools (like `live_search`) from a tools array.\n * Used before sending the request to the xAI API, since built-in tools\n * are controlled via `search_parameters` instead.\n */\nexport function filterXAIBuiltInTools<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends { [key: string]: any },\n>(payload?: { tools?: T[]; excludedTypes?: string[] }): T[] | undefined {\n if (!payload?.tools) {\n return undefined;\n }\n\n const filtered = payload.tools.filter((tool) => {\n if (tool == null || typeof tool !== \"object\") {\n return true;\n }\n\n if (!(\"type\" in tool)) {\n return true;\n }\n\n if (!payload?.excludedTypes?.length) {\n return true;\n }\n\n return !payload.excludedTypes.includes(tool.type);\n });\n\n return filtered.length > 0 ? filtered : undefined;\n}\n"],"mappings":";;;;;;;;;;AAiKA,SAAgB,kBACd,gBACA,YACA,YACiC;AACjC,KAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,WACrC;AAGF,QAAO;EACL,GAAI,cAAc,EAAE;EACpB,GAAI,kBAAkB,EAAE;EACxB,GAAI,cAAc,EAAE;EACrB;;;;;;AAOH,SAAgB,6BACd,QACwC;AACxC,KAAI,CAAC,OACH;CAGF,MAAM,UAAsC,EAC1C,MAAM,OAAO,QAAQ,QACtB;AAED,KAAI,OAAO,uBAAuB,KAAA,EAChC,SAAQ,qBAAqB,OAAO;AAEtC,KAAI,OAAO,cAAc,KAAA,EACvB,SAAQ,YAAY,OAAO;AAE7B,KAAI,OAAO,YAAY,KAAA,EACrB,SAAQ,UAAU,OAAO;AAE3B,KAAI,OAAO,qBAAqB,KAAA,EAC9B,SAAQ,mBAAmB,OAAO;AAEpC,KAAI,OAAO,WAAW,OAAO,QAAQ,SAAS,EAC5C,SAAQ,UAAU,OAAO;AAG3B,QAAO;;;;;;;AAQT,SAAgB,sBAGd,SAAsE;AACtE,KAAI,CAAC,SAAS,MACZ;CAGF,MAAM,WAAW,QAAQ,MAAM,QAAQ,SAAS;AAC9C,MAAI,QAAQ,QAAQ,OAAO,SAAS,SAClC,QAAO;AAGT,MAAI,EAAE,UAAU,MACd,QAAO;AAGT,MAAI,CAAC,SAAS,eAAe,OAC3B,QAAO;AAGT,SAAO,CAAC,QAAQ,cAAc,SAAS,KAAK,KAAK;GACjD;AAEF,QAAO,SAAS,SAAS,IAAI,WAAW,KAAA"}
package/dist/profiles.cjs CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  //#region src/profiles.ts
3
2
  const PROFILES = {
4
3
  "grok-3-fast-latest": {
@@ -268,7 +267,7 @@ const PROFILES = {
268
267
  structuredOutput: true
269
268
  }
270
269
  };
271
-
272
270
  //#endregion
273
271
  exports.default = PROFILES;
272
+
274
273
  //# sourceMappingURL=profiles.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"profiles.cjs","names":[],"sources":["../src/profiles.ts"],"sourcesContent":["/**\n * This file was automatically generated by an automated script. Do not edit manually.\n */\nimport type { ModelProfile } from \"@langchain/core/language_models/profile\";\nconst PROFILES: Record<string, ModelProfile> = {\n \"grok-3-fast-latest\": {\n maxInputTokens: 131072,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-2-vision\": {\n maxInputTokens: 8192,\n imageInputs: true,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 4096,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-3\": {\n maxInputTokens: 131072,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-code-fast-1\": {\n maxInputTokens: 256000,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 10000,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-2-vision-1212\": {\n maxInputTokens: 8192,\n imageInputs: true,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 4096,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-4-1-fast-non-reasoning\": {\n maxInputTokens: 2000000,\n imageInputs: true,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 30000,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-3-mini-fast\": {\n maxInputTokens: 131072,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-4-fast\": {\n maxInputTokens: 2000000,\n imageInputs: true,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 30000,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-4\": {\n maxInputTokens: 256000,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 64000,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-3-latest\": {\n maxInputTokens: 131072,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-4-1-fast\": {\n maxInputTokens: 2000000,\n imageInputs: true,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 30000,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-2-vision-latest\": {\n maxInputTokens: 8192,\n imageInputs: true,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 4096,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-3-mini-latest\": {\n maxInputTokens: 131072,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-3-mini\": {\n maxInputTokens: 131072,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-3-mini-fast-latest\": {\n maxInputTokens: 131072,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-2-latest\": {\n maxInputTokens: 131072,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-4-fast-non-reasoning\": {\n maxInputTokens: 2000000,\n imageInputs: true,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 30000,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-vision-beta\": {\n maxInputTokens: 8192,\n imageInputs: true,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 4096,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-3-fast\": {\n maxInputTokens: 131072,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n};\nexport default PROFILES;\n"],"mappings":";;AAIA,MAAM,WAAyC;CAC7C,sBAAsB;EACpB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,iBAAiB;EACf,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,UAAU;EACR,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,oBAAoB;EAClB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,sBAAsB;EACpB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,+BAA+B;EAC7B,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,oBAAoB;EAClB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,eAAe;EACb,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,UAAU;EACR,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,iBAAiB;EACf,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,iBAAiB;EACf,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,wBAAwB;EACtB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,sBAAsB;EACpB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,eAAe;EACb,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,2BAA2B;EACzB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,iBAAiB;EACf,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,6BAA6B;EAC3B,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,oBAAoB;EAClB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,eAAe;EACb,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACF"}
1
+ {"version":3,"file":"profiles.cjs","names":[],"sources":["../src/profiles.ts"],"sourcesContent":["/**\n * This file was automatically generated by an automated script. Do not edit manually.\n */\nimport type { ModelProfile } from \"@langchain/core/language_models/profile\";\nconst PROFILES: Record<string, ModelProfile> = {\n \"grok-3-fast-latest\": {\n maxInputTokens: 131072,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-2-vision\": {\n maxInputTokens: 8192,\n imageInputs: true,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 4096,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-3\": {\n maxInputTokens: 131072,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-code-fast-1\": {\n maxInputTokens: 256000,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 10000,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-2-vision-1212\": {\n maxInputTokens: 8192,\n imageInputs: true,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 4096,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-4-1-fast-non-reasoning\": {\n maxInputTokens: 2000000,\n imageInputs: true,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 30000,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-3-mini-fast\": {\n maxInputTokens: 131072,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-4-fast\": {\n maxInputTokens: 2000000,\n imageInputs: true,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 30000,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-4\": {\n maxInputTokens: 256000,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 64000,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-3-latest\": {\n maxInputTokens: 131072,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-4-1-fast\": {\n maxInputTokens: 2000000,\n imageInputs: true,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 30000,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-2-vision-latest\": {\n maxInputTokens: 8192,\n imageInputs: true,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 4096,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-3-mini-latest\": {\n maxInputTokens: 131072,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-3-mini\": {\n maxInputTokens: 131072,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-3-mini-fast-latest\": {\n maxInputTokens: 131072,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-2-latest\": {\n maxInputTokens: 131072,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-4-fast-non-reasoning\": {\n maxInputTokens: 2000000,\n imageInputs: true,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 30000,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-vision-beta\": {\n maxInputTokens: 8192,\n imageInputs: true,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 4096,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"grok-3-fast\": {\n maxInputTokens: 131072,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n};\nexport default PROFILES;\n"],"mappings":";AAIA,MAAM,WAAyC;CAC7C,sBAAsB;EACpB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,iBAAiB;EACf,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,UAAU;EACR,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,oBAAoB;EAClB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,sBAAsB;EACpB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,+BAA+B;EAC7B,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,oBAAoB;EAClB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,eAAe;EACb,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,UAAU;EACR,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,iBAAiB;EACf,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,iBAAiB;EACf,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,wBAAwB;EACtB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,sBAAsB;EACpB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,eAAe;EACb,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,2BAA2B;EACzB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,iBAAiB;EACf,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,6BAA6B;EAC3B,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,oBAAoB;EAClB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,eAAe;EACb,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACF"}
package/dist/profiles.js CHANGED
@@ -267,7 +267,7 @@ const PROFILES = {
267
267
  structuredOutput: true
268
268
  }
269
269
  };
270
-
271
270
  //#endregion
272
271
  export { PROFILES as default };
272
+
273
273
  //# sourceMappingURL=profiles.js.map
@@ -1,4 +1,3 @@
1
-
2
1
  //#region src/tools/code_execution.ts
3
2
  /**
4
3
  * xAI Code Execution tool type constant.
@@ -45,8 +44,8 @@ const XAI_CODE_EXECUTION_TOOL_TYPE = "code_interpreter";
45
44
  function xaiCodeExecution() {
46
45
  return { type: XAI_CODE_EXECUTION_TOOL_TYPE };
47
46
  }
48
-
49
47
  //#endregion
50
48
  exports.XAI_CODE_EXECUTION_TOOL_TYPE = XAI_CODE_EXECUTION_TOOL_TYPE;
51
49
  exports.xaiCodeExecution = xaiCodeExecution;
50
+
52
51
  //# sourceMappingURL=code_execution.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"code_execution.cjs","names":[],"sources":["../../src/tools/code_execution.ts"],"sourcesContent":["/**\n * xAI Code Execution tool type constant.\n * Note: The Responses API uses \"code_interpreter\" as the type name.\n */\nexport const XAI_CODE_EXECUTION_TOOL_TYPE = \"code_interpreter\";\n\n/**\n * xAI's built-in code execution tool interface.\n * Enables the model to write and execute Python code in real-time.\n *\n * This tool is part of xAI's agentic tool calling API and allows for:\n * - Mathematical computations\n * - Data analysis\n * - Financial modeling\n * - Scientific computing\n * - Code generation and testing\n */\nexport interface XAICodeExecutionTool {\n /**\n * The type of the tool. Must be \"code_interpreter\".\n */\n type: typeof XAI_CODE_EXECUTION_TOOL_TYPE;\n}\n\n/**\n * Creates an xAI code execution tool.\n * Enables the model to write and execute Python code in real-time for\n * calculations, data analysis, and complex computations.\n *\n * This tool is executed server-side by the xAI API in a secure, sandboxed\n * Python environment with common libraries pre-installed (NumPy, Pandas,\n * Matplotlib, SciPy).\n *\n * @returns An XAICodeExecutionTool object to pass to the model\n *\n * @example Basic usage\n * ```typescript\n * import { ChatXAIResponses, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAIResponses({\n * model: \"grok-4-1-fast\",\n * });\n *\n * const codeExecution = tools.xaiCodeExecution();\n * const result = await llm.invoke(\n * \"Calculate the compound interest for $10,000 at 5% annually for 10 years\",\n * { tools: [codeExecution] }\n * );\n * ```\n *\n * @example Combining with search tools\n * ```typescript\n * const webSearch = tools.xaiWebSearch();\n * const codeExecution = tools.xaiCodeExecution();\n *\n * const result = await llm.invoke(\n * \"Find the current stock price of AAPL and calculate what it would be worth with 10% annual growth over 5 years\",\n * { tools: [webSearch, codeExecution] }\n * );\n * ```\n */\nexport function xaiCodeExecution(): XAICodeExecutionTool {\n return {\n type: XAI_CODE_EXECUTION_TOOL_TYPE,\n };\n}\n"],"mappings":";;;;;;AAIA,MAAa,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyD5C,SAAgB,mBAAyC;AACvD,QAAO,EACL,MAAM,8BACP"}
1
+ {"version":3,"file":"code_execution.cjs","names":[],"sources":["../../src/tools/code_execution.ts"],"sourcesContent":["/**\n * xAI Code Execution tool type constant.\n * Note: The Responses API uses \"code_interpreter\" as the type name.\n */\nexport const XAI_CODE_EXECUTION_TOOL_TYPE = \"code_interpreter\";\n\n/**\n * xAI's built-in code execution tool interface.\n * Enables the model to write and execute Python code in real-time.\n *\n * This tool is part of xAI's agentic tool calling API and allows for:\n * - Mathematical computations\n * - Data analysis\n * - Financial modeling\n * - Scientific computing\n * - Code generation and testing\n */\nexport interface XAICodeExecutionTool {\n /**\n * The type of the tool. Must be \"code_interpreter\".\n */\n type: typeof XAI_CODE_EXECUTION_TOOL_TYPE;\n}\n\n/**\n * Creates an xAI code execution tool.\n * Enables the model to write and execute Python code in real-time for\n * calculations, data analysis, and complex computations.\n *\n * This tool is executed server-side by the xAI API in a secure, sandboxed\n * Python environment with common libraries pre-installed (NumPy, Pandas,\n * Matplotlib, SciPy).\n *\n * @returns An XAICodeExecutionTool object to pass to the model\n *\n * @example Basic usage\n * ```typescript\n * import { ChatXAIResponses, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAIResponses({\n * model: \"grok-4-1-fast\",\n * });\n *\n * const codeExecution = tools.xaiCodeExecution();\n * const result = await llm.invoke(\n * \"Calculate the compound interest for $10,000 at 5% annually for 10 years\",\n * { tools: [codeExecution] }\n * );\n * ```\n *\n * @example Combining with search tools\n * ```typescript\n * const webSearch = tools.xaiWebSearch();\n * const codeExecution = tools.xaiCodeExecution();\n *\n * const result = await llm.invoke(\n * \"Find the current stock price of AAPL and calculate what it would be worth with 10% annual growth over 5 years\",\n * { tools: [webSearch, codeExecution] }\n * );\n * ```\n */\nexport function xaiCodeExecution(): XAICodeExecutionTool {\n return {\n type: XAI_CODE_EXECUTION_TOOL_TYPE,\n };\n}\n"],"mappings":";;;;;AAIA,MAAa,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyD5C,SAAgB,mBAAyC;AACvD,QAAO,EACL,MAAM,8BACP"}
@@ -44,7 +44,7 @@ const XAI_CODE_EXECUTION_TOOL_TYPE = "code_interpreter";
44
44
  function xaiCodeExecution() {
45
45
  return { type: XAI_CODE_EXECUTION_TOOL_TYPE };
46
46
  }
47
-
48
47
  //#endregion
49
48
  export { XAI_CODE_EXECUTION_TOOL_TYPE, xaiCodeExecution };
49
+
50
50
  //# sourceMappingURL=code_execution.js.map
@@ -1,4 +1,3 @@
1
-
2
1
  //#region src/tools/collections_search.ts
3
2
  /**
4
3
  * xAI Collections Search tool type constant.
@@ -53,8 +52,8 @@ function xaiCollectionsSearch(options = {}) {
53
52
  if (options.vectorStoreIds !== void 0) tool.vector_store_ids = options.vectorStoreIds;
54
53
  return tool;
55
54
  }
56
-
57
55
  //#endregion
58
56
  exports.XAI_COLLECTIONS_SEARCH_TOOL_TYPE = XAI_COLLECTIONS_SEARCH_TOOL_TYPE;
59
57
  exports.xaiCollectionsSearch = xaiCollectionsSearch;
58
+
60
59
  //# sourceMappingURL=collections_search.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"collections_search.cjs","names":[],"sources":["../../src/tools/collections_search.ts"],"sourcesContent":["/**\n * xAI Collections Search tool type constant.\n * Note: The Responses API uses \"file_search\" as the type name.\n */\nexport const XAI_COLLECTIONS_SEARCH_TOOL_TYPE = \"file_search\";\n\n/**\n * xAI's built-in collections search tool interface.\n * Enables the model to search through uploaded knowledge bases (collections)\n * to retrieve relevant information from your documents.\n *\n * This tool is part of xAI's agentic tool calling API and is particularly\n * powerful for:\n * - Document retrieval from uploaded files\n * - Semantic search across knowledge bases\n * - RAG (Retrieval-Augmented Generation) applications\n * - Enterprise knowledge base queries\n */\nexport interface XAICollectionsSearchTool {\n /**\n * The type of the tool. Must be \"file_search\".\n */\n type: typeof XAI_COLLECTIONS_SEARCH_TOOL_TYPE;\n /**\n * List of vector store (collection) IDs to search.\n * These are the IDs of collections created via the xAI Collections API.\n */\n vector_store_ids?: string[];\n}\n\n/**\n * Options for the xAI collections search tool (camelCase).\n * All fields are camel-cased for the TypeScript API and are mapped to the\n * corresponding snake_case fields in the API request.\n */\nexport interface XAICollectionsSearchToolOptions {\n /**\n * List of vector store (collection) IDs to search.\n * These are the IDs of collections created via the xAI Collections API.\n *\n * @example [\"collection_abc123\", \"collection_def456\"]\n */\n vectorStoreIds?: string[];\n}\n\n/**\n * Creates an xAI collections search tool.\n * Enables the model to search through your uploaded knowledge bases (collections)\n * to retrieve relevant information from your documents.\n *\n * This tool is executed server-side by the xAI API as part of the agentic\n * tool calling workflow.\n *\n * @param options - Configuration options for the collections search tool\n * @returns An XAICollectionsSearchTool object to pass to the model\n *\n * @example Basic usage with collection IDs\n * ```typescript\n * import { ChatXAIResponses, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAIResponses({\n * model: \"grok-4-1-fast\",\n * });\n *\n * const collectionsSearch = tools.xaiCollectionsSearch({\n * vectorStoreIds: [\"collection_abc123\"],\n * });\n *\n * const result = await llm.invoke(\n * \"What are the key findings in the Q3 report?\",\n * { tools: [collectionsSearch] }\n * );\n * ```\n *\n * @example Combining with other tools for hybrid analysis\n * ```typescript\n * const collectionsSearch = tools.xaiCollectionsSearch({\n * vectorStoreIds: [\"collection_sec_filings\"],\n * });\n * const webSearch = tools.xaiWebSearch();\n * const codeExecution = tools.xaiCodeExecution();\n *\n * const result = await llm.invoke(\n * \"Based on our internal SEC filings, what is the market sentiment on our performance?\",\n * { tools: [collectionsSearch, webSearch, codeExecution] }\n * );\n * ```\n */\nexport function xaiCollectionsSearch(\n options: XAICollectionsSearchToolOptions = {}\n): XAICollectionsSearchTool {\n const tool: XAICollectionsSearchTool = {\n type: XAI_COLLECTIONS_SEARCH_TOOL_TYPE,\n };\n\n if (options.vectorStoreIds !== undefined) {\n tool.vector_store_ids = options.vectorStoreIds;\n }\n\n return tool;\n}\n"],"mappings":";;;;;;AAIA,MAAa,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFhD,SAAgB,qBACd,UAA2C,EAAE,EACnB;CAC1B,MAAM,OAAiC,EACrC,MAAM,kCACP;AAED,KAAI,QAAQ,mBAAmB,OAC7B,MAAK,mBAAmB,QAAQ;AAGlC,QAAO"}
1
+ {"version":3,"file":"collections_search.cjs","names":[],"sources":["../../src/tools/collections_search.ts"],"sourcesContent":["/**\n * xAI Collections Search tool type constant.\n * Note: The Responses API uses \"file_search\" as the type name.\n */\nexport const XAI_COLLECTIONS_SEARCH_TOOL_TYPE = \"file_search\";\n\n/**\n * xAI's built-in collections search tool interface.\n * Enables the model to search through uploaded knowledge bases (collections)\n * to retrieve relevant information from your documents.\n *\n * This tool is part of xAI's agentic tool calling API and is particularly\n * powerful for:\n * - Document retrieval from uploaded files\n * - Semantic search across knowledge bases\n * - RAG (Retrieval-Augmented Generation) applications\n * - Enterprise knowledge base queries\n */\nexport interface XAICollectionsSearchTool {\n /**\n * The type of the tool. Must be \"file_search\".\n */\n type: typeof XAI_COLLECTIONS_SEARCH_TOOL_TYPE;\n /**\n * List of vector store (collection) IDs to search.\n * These are the IDs of collections created via the xAI Collections API.\n */\n vector_store_ids?: string[];\n}\n\n/**\n * Options for the xAI collections search tool (camelCase).\n * All fields are camel-cased for the TypeScript API and are mapped to the\n * corresponding snake_case fields in the API request.\n */\nexport interface XAICollectionsSearchToolOptions {\n /**\n * List of vector store (collection) IDs to search.\n * These are the IDs of collections created via the xAI Collections API.\n *\n * @example [\"collection_abc123\", \"collection_def456\"]\n */\n vectorStoreIds?: string[];\n}\n\n/**\n * Creates an xAI collections search tool.\n * Enables the model to search through your uploaded knowledge bases (collections)\n * to retrieve relevant information from your documents.\n *\n * This tool is executed server-side by the xAI API as part of the agentic\n * tool calling workflow.\n *\n * @param options - Configuration options for the collections search tool\n * @returns An XAICollectionsSearchTool object to pass to the model\n *\n * @example Basic usage with collection IDs\n * ```typescript\n * import { ChatXAIResponses, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAIResponses({\n * model: \"grok-4-1-fast\",\n * });\n *\n * const collectionsSearch = tools.xaiCollectionsSearch({\n * vectorStoreIds: [\"collection_abc123\"],\n * });\n *\n * const result = await llm.invoke(\n * \"What are the key findings in the Q3 report?\",\n * { tools: [collectionsSearch] }\n * );\n * ```\n *\n * @example Combining with other tools for hybrid analysis\n * ```typescript\n * const collectionsSearch = tools.xaiCollectionsSearch({\n * vectorStoreIds: [\"collection_sec_filings\"],\n * });\n * const webSearch = tools.xaiWebSearch();\n * const codeExecution = tools.xaiCodeExecution();\n *\n * const result = await llm.invoke(\n * \"Based on our internal SEC filings, what is the market sentiment on our performance?\",\n * { tools: [collectionsSearch, webSearch, codeExecution] }\n * );\n * ```\n */\nexport function xaiCollectionsSearch(\n options: XAICollectionsSearchToolOptions = {}\n): XAICollectionsSearchTool {\n const tool: XAICollectionsSearchTool = {\n type: XAI_COLLECTIONS_SEARCH_TOOL_TYPE,\n };\n\n if (options.vectorStoreIds !== undefined) {\n tool.vector_store_ids = options.vectorStoreIds;\n }\n\n return tool;\n}\n"],"mappings":";;;;;AAIA,MAAa,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFhD,SAAgB,qBACd,UAA2C,EAAE,EACnB;CAC1B,MAAM,OAAiC,EACrC,MAAM,kCACP;AAED,KAAI,QAAQ,mBAAmB,KAAA,EAC7B,MAAK,mBAAmB,QAAQ;AAGlC,QAAO"}
@@ -52,7 +52,7 @@ function xaiCollectionsSearch(options = {}) {
52
52
  if (options.vectorStoreIds !== void 0) tool.vector_store_ids = options.vectorStoreIds;
53
53
  return tool;
54
54
  }
55
-
56
55
  //#endregion
57
56
  export { XAI_COLLECTIONS_SEARCH_TOOL_TYPE, xaiCollectionsSearch };
57
+
58
58
  //# sourceMappingURL=collections_search.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collections_search.js","names":[],"sources":["../../src/tools/collections_search.ts"],"sourcesContent":["/**\n * xAI Collections Search tool type constant.\n * Note: The Responses API uses \"file_search\" as the type name.\n */\nexport const XAI_COLLECTIONS_SEARCH_TOOL_TYPE = \"file_search\";\n\n/**\n * xAI's built-in collections search tool interface.\n * Enables the model to search through uploaded knowledge bases (collections)\n * to retrieve relevant information from your documents.\n *\n * This tool is part of xAI's agentic tool calling API and is particularly\n * powerful for:\n * - Document retrieval from uploaded files\n * - Semantic search across knowledge bases\n * - RAG (Retrieval-Augmented Generation) applications\n * - Enterprise knowledge base queries\n */\nexport interface XAICollectionsSearchTool {\n /**\n * The type of the tool. Must be \"file_search\".\n */\n type: typeof XAI_COLLECTIONS_SEARCH_TOOL_TYPE;\n /**\n * List of vector store (collection) IDs to search.\n * These are the IDs of collections created via the xAI Collections API.\n */\n vector_store_ids?: string[];\n}\n\n/**\n * Options for the xAI collections search tool (camelCase).\n * All fields are camel-cased for the TypeScript API and are mapped to the\n * corresponding snake_case fields in the API request.\n */\nexport interface XAICollectionsSearchToolOptions {\n /**\n * List of vector store (collection) IDs to search.\n * These are the IDs of collections created via the xAI Collections API.\n *\n * @example [\"collection_abc123\", \"collection_def456\"]\n */\n vectorStoreIds?: string[];\n}\n\n/**\n * Creates an xAI collections search tool.\n * Enables the model to search through your uploaded knowledge bases (collections)\n * to retrieve relevant information from your documents.\n *\n * This tool is executed server-side by the xAI API as part of the agentic\n * tool calling workflow.\n *\n * @param options - Configuration options for the collections search tool\n * @returns An XAICollectionsSearchTool object to pass to the model\n *\n * @example Basic usage with collection IDs\n * ```typescript\n * import { ChatXAIResponses, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAIResponses({\n * model: \"grok-4-1-fast\",\n * });\n *\n * const collectionsSearch = tools.xaiCollectionsSearch({\n * vectorStoreIds: [\"collection_abc123\"],\n * });\n *\n * const result = await llm.invoke(\n * \"What are the key findings in the Q3 report?\",\n * { tools: [collectionsSearch] }\n * );\n * ```\n *\n * @example Combining with other tools for hybrid analysis\n * ```typescript\n * const collectionsSearch = tools.xaiCollectionsSearch({\n * vectorStoreIds: [\"collection_sec_filings\"],\n * });\n * const webSearch = tools.xaiWebSearch();\n * const codeExecution = tools.xaiCodeExecution();\n *\n * const result = await llm.invoke(\n * \"Based on our internal SEC filings, what is the market sentiment on our performance?\",\n * { tools: [collectionsSearch, webSearch, codeExecution] }\n * );\n * ```\n */\nexport function xaiCollectionsSearch(\n options: XAICollectionsSearchToolOptions = {}\n): XAICollectionsSearchTool {\n const tool: XAICollectionsSearchTool = {\n type: XAI_COLLECTIONS_SEARCH_TOOL_TYPE,\n };\n\n if (options.vectorStoreIds !== undefined) {\n tool.vector_store_ids = options.vectorStoreIds;\n }\n\n return tool;\n}\n"],"mappings":";;;;;AAIA,MAAa,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFhD,SAAgB,qBACd,UAA2C,EAAE,EACnB;CAC1B,MAAM,OAAiC,EACrC,MAAM,kCACP;AAED,KAAI,QAAQ,mBAAmB,OAC7B,MAAK,mBAAmB,QAAQ;AAGlC,QAAO"}
1
+ {"version":3,"file":"collections_search.js","names":[],"sources":["../../src/tools/collections_search.ts"],"sourcesContent":["/**\n * xAI Collections Search tool type constant.\n * Note: The Responses API uses \"file_search\" as the type name.\n */\nexport const XAI_COLLECTIONS_SEARCH_TOOL_TYPE = \"file_search\";\n\n/**\n * xAI's built-in collections search tool interface.\n * Enables the model to search through uploaded knowledge bases (collections)\n * to retrieve relevant information from your documents.\n *\n * This tool is part of xAI's agentic tool calling API and is particularly\n * powerful for:\n * - Document retrieval from uploaded files\n * - Semantic search across knowledge bases\n * - RAG (Retrieval-Augmented Generation) applications\n * - Enterprise knowledge base queries\n */\nexport interface XAICollectionsSearchTool {\n /**\n * The type of the tool. Must be \"file_search\".\n */\n type: typeof XAI_COLLECTIONS_SEARCH_TOOL_TYPE;\n /**\n * List of vector store (collection) IDs to search.\n * These are the IDs of collections created via the xAI Collections API.\n */\n vector_store_ids?: string[];\n}\n\n/**\n * Options for the xAI collections search tool (camelCase).\n * All fields are camel-cased for the TypeScript API and are mapped to the\n * corresponding snake_case fields in the API request.\n */\nexport interface XAICollectionsSearchToolOptions {\n /**\n * List of vector store (collection) IDs to search.\n * These are the IDs of collections created via the xAI Collections API.\n *\n * @example [\"collection_abc123\", \"collection_def456\"]\n */\n vectorStoreIds?: string[];\n}\n\n/**\n * Creates an xAI collections search tool.\n * Enables the model to search through your uploaded knowledge bases (collections)\n * to retrieve relevant information from your documents.\n *\n * This tool is executed server-side by the xAI API as part of the agentic\n * tool calling workflow.\n *\n * @param options - Configuration options for the collections search tool\n * @returns An XAICollectionsSearchTool object to pass to the model\n *\n * @example Basic usage with collection IDs\n * ```typescript\n * import { ChatXAIResponses, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAIResponses({\n * model: \"grok-4-1-fast\",\n * });\n *\n * const collectionsSearch = tools.xaiCollectionsSearch({\n * vectorStoreIds: [\"collection_abc123\"],\n * });\n *\n * const result = await llm.invoke(\n * \"What are the key findings in the Q3 report?\",\n * { tools: [collectionsSearch] }\n * );\n * ```\n *\n * @example Combining with other tools for hybrid analysis\n * ```typescript\n * const collectionsSearch = tools.xaiCollectionsSearch({\n * vectorStoreIds: [\"collection_sec_filings\"],\n * });\n * const webSearch = tools.xaiWebSearch();\n * const codeExecution = tools.xaiCodeExecution();\n *\n * const result = await llm.invoke(\n * \"Based on our internal SEC filings, what is the market sentiment on our performance?\",\n * { tools: [collectionsSearch, webSearch, codeExecution] }\n * );\n * ```\n */\nexport function xaiCollectionsSearch(\n options: XAICollectionsSearchToolOptions = {}\n): XAICollectionsSearchTool {\n const tool: XAICollectionsSearchTool = {\n type: XAI_COLLECTIONS_SEARCH_TOOL_TYPE,\n };\n\n if (options.vectorStoreIds !== undefined) {\n tool.vector_store_ids = options.vectorStoreIds;\n }\n\n return tool;\n}\n"],"mappings":";;;;;AAIA,MAAa,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFhD,SAAgB,qBACd,UAA2C,EAAE,EACnB;CAC1B,MAAM,OAAiC,EACrC,MAAM,kCACP;AAED,KAAI,QAAQ,mBAAmB,KAAA,EAC7B,MAAK,mBAAmB,QAAQ;AAGlC,QAAO"}
@@ -1,9 +1,8 @@
1
- const require_live_search = require('./live_search.cjs');
2
- const require_web_search = require('./web_search.cjs');
3
- const require_x_search = require('./x_search.cjs');
4
- const require_code_execution = require('./code_execution.cjs');
5
- const require_collections_search = require('./collections_search.cjs');
6
-
1
+ const require_live_search = require("./live_search.cjs");
2
+ const require_web_search = require("./web_search.cjs");
3
+ const require_x_search = require("./x_search.cjs");
4
+ const require_code_execution = require("./code_execution.cjs");
5
+ const require_collections_search = require("./collections_search.cjs");
7
6
  //#region src/tools/index.ts
8
7
  const tools = {
9
8
  xaiLiveSearch: require_live_search.xaiLiveSearch,
@@ -12,7 +11,7 @@ const tools = {
12
11
  xaiCodeExecution: require_code_execution.xaiCodeExecution,
13
12
  xaiCollectionsSearch: require_collections_search.xaiCollectionsSearch
14
13
  };
15
-
16
14
  //#endregion
17
15
  exports.tools = tools;
16
+
18
17
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../src/tools/index.ts"],"sourcesContent":["import { xaiLiveSearch } from \"./live_search.js\";\nimport { xaiWebSearch } from \"./web_search.js\";\nimport { xaiXSearch } from \"./x_search.js\";\nimport { xaiCodeExecution } from \"./code_execution.js\";\nimport { xaiCollectionsSearch } from \"./collections_search.js\";\n\nexport const tools = {\n /** @deprecated Use xaiWebSearch and xaiXSearch instead */\n xaiLiveSearch,\n xaiWebSearch,\n xaiXSearch,\n xaiCodeExecution,\n xaiCollectionsSearch,\n};\n\n// Re-export types for convenience\nexport type {\n XAILiveSearchTool,\n XAILiveSearchToolOptions,\n} from \"./live_search.js\";\nexport type {\n XAIWebSearchTool,\n XAIWebSearchToolOptions,\n} from \"./web_search.js\";\nexport type { XAIXSearchTool, XAIXSearchToolOptions } from \"./x_search.js\";\nexport type { XAICodeExecutionTool } from \"./code_execution.js\";\nexport type {\n XAICollectionsSearchTool,\n XAICollectionsSearchToolOptions,\n} from \"./collections_search.js\";\n\n// Re-export tool type constants\nexport {\n XAI_LIVE_SEARCH_TOOL_TYPE,\n XAI_LIVE_SEARCH_TOOL_NAME,\n} from \"./live_search.js\";\nexport { XAI_WEB_SEARCH_TOOL_TYPE } from \"./web_search.js\";\nexport { XAI_X_SEARCH_TOOL_TYPE } from \"./x_search.js\";\nexport { XAI_CODE_EXECUTION_TOOL_TYPE } from \"./code_execution.js\";\nexport { XAI_COLLECTIONS_SEARCH_TOOL_TYPE } from \"./collections_search.js\";\n"],"mappings":";;;;;;;AAMA,MAAa,QAAQ;CAEnB;CACA;CACA;CACA;CACA;CACD"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/tools/index.ts"],"sourcesContent":["import { xaiLiveSearch } from \"./live_search.js\";\nimport { xaiWebSearch } from \"./web_search.js\";\nimport { xaiXSearch } from \"./x_search.js\";\nimport { xaiCodeExecution } from \"./code_execution.js\";\nimport { xaiCollectionsSearch } from \"./collections_search.js\";\n\nexport const tools = {\n /** @deprecated Use xaiWebSearch and xaiXSearch instead */\n xaiLiveSearch,\n xaiWebSearch,\n xaiXSearch,\n xaiCodeExecution,\n xaiCollectionsSearch,\n};\n\n// Re-export types for convenience\nexport type {\n XAILiveSearchTool,\n XAILiveSearchToolOptions,\n} from \"./live_search.js\";\nexport type {\n XAIWebSearchTool,\n XAIWebSearchToolOptions,\n} from \"./web_search.js\";\nexport type { XAIXSearchTool, XAIXSearchToolOptions } from \"./x_search.js\";\nexport type { XAICodeExecutionTool } from \"./code_execution.js\";\nexport type {\n XAICollectionsSearchTool,\n XAICollectionsSearchToolOptions,\n} from \"./collections_search.js\";\n\n// Re-export tool type constants\nexport {\n XAI_LIVE_SEARCH_TOOL_TYPE,\n XAI_LIVE_SEARCH_TOOL_NAME,\n} from \"./live_search.js\";\nexport { XAI_WEB_SEARCH_TOOL_TYPE } from \"./web_search.js\";\nexport { XAI_X_SEARCH_TOOL_TYPE } from \"./x_search.js\";\nexport { XAI_CODE_EXECUTION_TOOL_TYPE } from \"./code_execution.js\";\nexport { XAI_COLLECTIONS_SEARCH_TOOL_TYPE } from \"./collections_search.js\";\n"],"mappings":";;;;;;AAMA,MAAa,QAAQ;CAEnB,eAAA,oBAAA;CACA,cAAA,mBAAA;CACA,YAAA,iBAAA;CACA,kBAAA,uBAAA;CACA,sBAAA,2BAAA;CACD"}
@@ -1,9 +1,8 @@
1
- import { XAI_LIVE_SEARCH_TOOL_NAME, XAI_LIVE_SEARCH_TOOL_TYPE, xaiLiveSearch } from "./live_search.js";
2
- import { XAI_WEB_SEARCH_TOOL_TYPE, xaiWebSearch } from "./web_search.js";
3
- import { XAI_X_SEARCH_TOOL_TYPE, xaiXSearch } from "./x_search.js";
4
- import { XAI_CODE_EXECUTION_TOOL_TYPE, xaiCodeExecution } from "./code_execution.js";
5
- import { XAI_COLLECTIONS_SEARCH_TOOL_TYPE, xaiCollectionsSearch } from "./collections_search.js";
6
-
1
+ import { xaiLiveSearch } from "./live_search.js";
2
+ import { xaiWebSearch } from "./web_search.js";
3
+ import { xaiXSearch } from "./x_search.js";
4
+ import { xaiCodeExecution } from "./code_execution.js";
5
+ import { xaiCollectionsSearch } from "./collections_search.js";
7
6
  //#region src/tools/index.ts
8
7
  const tools = {
9
8
  xaiLiveSearch,
@@ -12,7 +11,7 @@ const tools = {
12
11
  xaiCodeExecution,
13
12
  xaiCollectionsSearch
14
13
  };
15
-
16
14
  //#endregion
17
15
  export { tools };
16
+
18
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/tools/index.ts"],"sourcesContent":["import { xaiLiveSearch } from \"./live_search.js\";\nimport { xaiWebSearch } from \"./web_search.js\";\nimport { xaiXSearch } from \"./x_search.js\";\nimport { xaiCodeExecution } from \"./code_execution.js\";\nimport { xaiCollectionsSearch } from \"./collections_search.js\";\n\nexport const tools = {\n /** @deprecated Use xaiWebSearch and xaiXSearch instead */\n xaiLiveSearch,\n xaiWebSearch,\n xaiXSearch,\n xaiCodeExecution,\n xaiCollectionsSearch,\n};\n\n// Re-export types for convenience\nexport type {\n XAILiveSearchTool,\n XAILiveSearchToolOptions,\n} from \"./live_search.js\";\nexport type {\n XAIWebSearchTool,\n XAIWebSearchToolOptions,\n} from \"./web_search.js\";\nexport type { XAIXSearchTool, XAIXSearchToolOptions } from \"./x_search.js\";\nexport type { XAICodeExecutionTool } from \"./code_execution.js\";\nexport type {\n XAICollectionsSearchTool,\n XAICollectionsSearchToolOptions,\n} from \"./collections_search.js\";\n\n// Re-export tool type constants\nexport {\n XAI_LIVE_SEARCH_TOOL_TYPE,\n XAI_LIVE_SEARCH_TOOL_NAME,\n} from \"./live_search.js\";\nexport { XAI_WEB_SEARCH_TOOL_TYPE } from \"./web_search.js\";\nexport { XAI_X_SEARCH_TOOL_TYPE } from \"./x_search.js\";\nexport { XAI_CODE_EXECUTION_TOOL_TYPE } from \"./code_execution.js\";\nexport { XAI_COLLECTIONS_SEARCH_TOOL_TYPE } from \"./collections_search.js\";\n"],"mappings":";;;;;;;AAMA,MAAa,QAAQ;CAEnB;CACA;CACA;CACA;CACA;CACD"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/tools/index.ts"],"sourcesContent":["import { xaiLiveSearch } from \"./live_search.js\";\nimport { xaiWebSearch } from \"./web_search.js\";\nimport { xaiXSearch } from \"./x_search.js\";\nimport { xaiCodeExecution } from \"./code_execution.js\";\nimport { xaiCollectionsSearch } from \"./collections_search.js\";\n\nexport const tools = {\n /** @deprecated Use xaiWebSearch and xaiXSearch instead */\n xaiLiveSearch,\n xaiWebSearch,\n xaiXSearch,\n xaiCodeExecution,\n xaiCollectionsSearch,\n};\n\n// Re-export types for convenience\nexport type {\n XAILiveSearchTool,\n XAILiveSearchToolOptions,\n} from \"./live_search.js\";\nexport type {\n XAIWebSearchTool,\n XAIWebSearchToolOptions,\n} from \"./web_search.js\";\nexport type { XAIXSearchTool, XAIXSearchToolOptions } from \"./x_search.js\";\nexport type { XAICodeExecutionTool } from \"./code_execution.js\";\nexport type {\n XAICollectionsSearchTool,\n XAICollectionsSearchToolOptions,\n} from \"./collections_search.js\";\n\n// Re-export tool type constants\nexport {\n XAI_LIVE_SEARCH_TOOL_TYPE,\n XAI_LIVE_SEARCH_TOOL_NAME,\n} from \"./live_search.js\";\nexport { XAI_WEB_SEARCH_TOOL_TYPE } from \"./web_search.js\";\nexport { XAI_X_SEARCH_TOOL_TYPE } from \"./x_search.js\";\nexport { XAI_CODE_EXECUTION_TOOL_TYPE } from \"./code_execution.js\";\nexport { XAI_COLLECTIONS_SEARCH_TOOL_TYPE } from \"./collections_search.js\";\n"],"mappings":";;;;;;AAMA,MAAa,QAAQ;CAEnB;CACA;CACA;CACA;CACA;CACD"}
@@ -1,4 +1,3 @@
1
-
2
1
  //#region src/tools/live_search.ts
3
2
  /**
4
3
  * xAI's deprecated live_search tool type.
@@ -83,9 +82,9 @@ function xaiLiveSearch(options = {}) {
83
82
  sources: options?.sources?.map(mapToolSourceToSearchSource)
84
83
  };
85
84
  }
86
-
87
85
  //#endregion
88
86
  exports.XAI_LIVE_SEARCH_TOOL_NAME = XAI_LIVE_SEARCH_TOOL_NAME;
89
87
  exports.XAI_LIVE_SEARCH_TOOL_TYPE = XAI_LIVE_SEARCH_TOOL_TYPE;
90
88
  exports.xaiLiveSearch = xaiLiveSearch;
89
+
91
90
  //# sourceMappingURL=live_search.cjs.map