Skip to content

Commit 1c51805

Browse files
committed
fix: put metadata on tool def
This allows the following flow to work for tools with metadata: parse file -> pass tools from parsed file to evaluate. Signed-off-by: Donnie Adams <[email protected]>
1 parent 712d463 commit 1c51805

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/gptscript.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ export interface ToolDef {
680680
credentials?: string[]
681681
instructions?: string
682682
type?: string
683+
metaData?: Record<string, string>
683684
}
684685

685686
export interface ToolReference {
@@ -695,7 +696,6 @@ export interface Tool extends ToolDef {
695696
id: string
696697
type: typeof ToolType
697698
toolMapping?: Record<string, ToolReference[]>
698-
metaData?: Record<string, string>
699699
localTools?: Record<string, string>
700700
source?: SourceRef
701701
workingDir?: string

tests/gptscript.test.ts

+18-2
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ describe("gptscript module", () => {
361361

362362
const inputs = [
363363
"List the 3 largest of the Great Lakes by volume.",
364-
"What is the volume of the second one in cubic miles?",
365-
"What is the total area of the third one in square miles?"
364+
"What is the volume of the second in the list in cubic miles?",
365+
"What is the total area of the third in the list in square miles?"
366366
]
367367

368368
const expectedOutputs = [
@@ -569,4 +569,20 @@ describe("gptscript module", () => {
569569
expect(err).toEqual(undefined)
570570
expect(out).toEqual("200")
571571
}, 20000)
572+
573+
test("run parsed tool with metadata", async () => {
574+
let err = undefined
575+
let out = ""
576+
let tools = await g.parse(path.join(__dirname, "fixtures", "parse-with-metadata.gpt"))
577+
578+
let run = await g.evaluate(tools[0])
579+
580+
try {
581+
out = await run.text()
582+
} catch (e) {
583+
err = e
584+
}
585+
expect(err).toEqual(undefined)
586+
expect(out).toEqual("200")
587+
}, 20000)
572588
})

0 commit comments

Comments
 (0)