-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core[patch]: Allow runnable tools to take single string/
ToolCall
in…
…puts (#6096) * core[patch]: Allow runnable tools to take single string inputs * add test for tool func * chore: lint files * cr * cr * cr * fix types * rename ZodAny to ZodObjectAny * docstring nits * fiox * cr * cr
- Loading branch information
1 parent
2c000dd
commit 1c4b2d8
Showing
8 changed files
with
194 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ToolCall } from "../messages/tool.js"; | ||
|
||
export function _isToolCall(toolCall?: unknown): toolCall is ToolCall { | ||
return !!( | ||
toolCall && | ||
typeof toolCall === "object" && | ||
"type" in toolCall && | ||
toolCall.type === "tool_call" | ||
); | ||
} | ||
|
||
/** | ||
* Custom error class used to handle exceptions related to tool input parsing. | ||
* It extends the built-in `Error` class and adds an optional `output` | ||
* property that can hold the output that caused the exception. | ||
*/ | ||
export class ToolInputParsingException extends Error { | ||
output?: string; | ||
|
||
constructor(message: string, output?: string) { | ||
super(message); | ||
this.output = output; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import type { z } from "zod"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export type ZodAny = z.ZodObject<any, any, any, any>; | ||
export type ZodObjectAny = z.ZodObject<any, any, any, any>; |
Oops, something went wrong.