@baseai/core
Advanced tools
Comparing version 0.9.38 to 0.9.39
# `baseai` SDK | ||
## 0.9.39 | ||
### Patch Changes | ||
- 📦 NEW: tools support in pipe.run() | ||
## 0.9.38 | ||
@@ -4,0 +10,0 @@ |
@@ -44,3 +44,3 @@ import { ChatCompletionStream } from 'openai/lib/ChatCompletionStream'; | ||
} | ||
interface ToolCall { | ||
interface ToolCallResult { | ||
id: string; | ||
@@ -55,3 +55,3 @@ type: 'function'; | ||
tool_call_id?: string; | ||
tool_calls?: ToolCall[]; | ||
tool_calls?: ToolCallResult[]; | ||
} | ||
@@ -66,2 +66,10 @@ interface ToolFunction { | ||
type ToolChoice = 'auto' | 'required' | ToolChoiceFunction; | ||
interface Tools { | ||
type: 'function'; | ||
function: { | ||
name: string; | ||
description?: string; | ||
parameters?: Record<string, any>; | ||
}; | ||
} | ||
type Model = OpenAIModels | TogetherModels | AnthropicModels | GroqModels | GoogleModels | CohereModels | FireworksAIModels | PerplexityModels | MistralAIModels | XAIModels | OllamaModels; | ||
@@ -114,2 +122,3 @@ interface Pipe$1 { | ||
runTools?: boolean; | ||
tools?: Tools[]; | ||
name?: string; | ||
@@ -201,3 +210,3 @@ apiKey?: string; | ||
type: 'toolCall'; | ||
toolCall: ToolCall; | ||
toolCall: ToolCallResult; | ||
} | ||
@@ -213,3 +222,3 @@ interface ChoiceStream { | ||
content?: string; | ||
tool_calls?: ToolCall[]; | ||
tool_calls?: ToolCallResult[]; | ||
} | ||
@@ -230,3 +239,3 @@ interface UnknownChunk { | ||
content?: string; | ||
toolCall?: ToolCall; | ||
toolCall?: ToolCallResult; | ||
rawChunk?: ChunkStream; | ||
@@ -347,4 +356,4 @@ } | ||
*/ | ||
declare function getToolsFromStream(stream: ReadableStream<any>): Promise<ToolCall[]>; | ||
declare function getToolsFromStream(stream: ReadableStream<any>): Promise<ToolCallResult[]>; | ||
export { type Chunk, type ChunkStream, type Memory as MemoryI, type Message, type MessageRole, Pipe, type Pipe$1 as PipeI, type PipeOptions, type RunOptions, type RunOptionsStream, type RunResponse, type RunResponseStream, type Runner, type Tool as ToolI, type Usage, type Variable, fromReadableStream, generateText, getRunner, getTextContent, getTextDelta, getTextPart, getToolsFromStream, handleResponseStream, isContent, isToolCall, isUnknown, printStreamToStdout, processChunk, streamText }; |
@@ -849,3 +849,5 @@ "use strict"; | ||
if (!toolFunction) { | ||
throw new Error(`Tool '${toolName}' not found`); | ||
throw new Error( | ||
`Tool ${toolName} not found. If this is intentional, please set runTools to false to disable tool execution by default.` | ||
); | ||
} | ||
@@ -930,3 +932,3 @@ const toolResponse = await toolFunction(toolParameters); | ||
async run(options) { | ||
var _a; | ||
var _a, _b; | ||
const endpoint = "/v1/pipes/run"; | ||
@@ -951,3 +953,6 @@ const providerString = this.pipe.model.split(":")[0]; | ||
} | ||
const runTools = (_a = options.runTools) != null ? _a : true; | ||
let runTools = (_a = options.runTools) != null ? _a : true; | ||
if (options.tools && ((_b = options.tools) == null ? void 0 : _b.length)) { | ||
runTools = false; | ||
} | ||
delete options.runTools; | ||
@@ -954,0 +959,0 @@ const body = { ...options, stream }; |
@@ -8,3 +8,3 @@ import { ChatCompletionStream } from 'openai/lib/ChatCompletionStream'; | ||
} | ||
interface ToolCall { | ||
interface ToolCallResult { | ||
id: string; | ||
@@ -24,3 +24,3 @@ type: 'function'; | ||
content?: string; | ||
tool_calls?: ToolCall[]; | ||
tool_calls?: ToolCallResult[]; | ||
} | ||
@@ -87,4 +87,4 @@ interface ChunkStream { | ||
*/ | ||
declare function getToolsFromStream(stream: ReadableStream<any>): Promise<ToolCall[]>; | ||
declare function getToolsFromStream(stream: ReadableStream<any>): Promise<ToolCallResult[]>; | ||
export { type Runner, fromReadableStream, getRunner, getTextPart, getToolsFromStream, handleResponseStream }; |
{ | ||
"name": "@baseai/core", | ||
"description": "The Web AI Framework's core - BaseAI.dev", | ||
"version": "0.9.38", | ||
"version": "0.9.39", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "sideEffects": false, |
@@ -20,3 +20,3 @@ import { ChatCompletionStream } from 'openai/lib/ChatCompletionStream'; | ||
} | ||
interface ToolCall { | ||
interface ToolCallResult { | ||
id: string; | ||
@@ -31,3 +31,3 @@ type: 'function'; | ||
tool_call_id?: string; | ||
tool_calls?: ToolCall[]; | ||
tool_calls?: ToolCallResult[]; | ||
} | ||
@@ -42,2 +42,10 @@ interface ToolFunction { | ||
type ToolChoice = 'auto' | 'required' | ToolChoiceFunction; | ||
interface Tools { | ||
type: 'function'; | ||
function: { | ||
name: string; | ||
description?: string; | ||
parameters?: Record<string, any>; | ||
}; | ||
} | ||
type Model = OpenAIModels | TogetherModels | AnthropicModels | GroqModels | GoogleModels | CohereModels | FireworksAIModels | PerplexityModels | MistralAIModels | XAIModels | OllamaModels; | ||
@@ -83,2 +91,3 @@ interface Pipe$1 { | ||
runTools?: boolean; | ||
tools?: Tools[]; | ||
name?: string; | ||
@@ -170,3 +179,3 @@ apiKey?: string; | ||
type: 'toolCall'; | ||
toolCall: ToolCall; | ||
toolCall: ToolCallResult; | ||
} | ||
@@ -182,3 +191,3 @@ interface ChoiceStream { | ||
content?: string; | ||
tool_calls?: ToolCall[]; | ||
tool_calls?: ToolCallResult[]; | ||
} | ||
@@ -199,3 +208,3 @@ interface UnknownChunk { | ||
content?: string; | ||
toolCall?: ToolCall; | ||
toolCall?: ToolCallResult; | ||
rawChunk?: ChunkStream; | ||
@@ -202,0 +211,0 @@ } |
@@ -840,3 +840,5 @@ "use strict"; | ||
if (!toolFunction) { | ||
throw new Error(`Tool '${toolName}' not found`); | ||
throw new Error( | ||
`Tool ${toolName} not found. If this is intentional, please set runTools to false to disable tool execution by default.` | ||
); | ||
} | ||
@@ -921,3 +923,3 @@ const toolResponse = await toolFunction(toolParameters); | ||
async run(options) { | ||
var _a; | ||
var _a, _b; | ||
const endpoint = "/v1/pipes/run"; | ||
@@ -942,3 +944,6 @@ const providerString = this.pipe.model.split(":")[0]; | ||
} | ||
const runTools = (_a = options.runTools) != null ? _a : true; | ||
let runTools = (_a = options.runTools) != null ? _a : true; | ||
if (options.tools && ((_b = options.tools) == null ? void 0 : _b.length)) { | ||
runTools = false; | ||
} | ||
delete options.runTools; | ||
@@ -945,0 +950,0 @@ const body = { ...options, stream }; |
@@ -8,3 +8,3 @@ import React from 'react'; | ||
} | ||
interface ToolCall { | ||
interface ToolCallResult { | ||
id: string; | ||
@@ -19,3 +19,3 @@ type: 'function'; | ||
tool_call_id?: string; | ||
tool_calls?: ToolCall[]; | ||
tool_calls?: ToolCallResult[]; | ||
} | ||
@@ -22,0 +22,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
475377
5595