Skip to content

Commit

Permalink
Merge pull request #78 from thedadams/metadata-to-tool-def
Browse files Browse the repository at this point in the history
fix: put metadata on tool def
  • Loading branch information
thedadams authored Aug 8, 2024
2 parents 712d463 + 1c51805 commit af7622e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/gptscript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ export interface ToolDef {
credentials?: string[]
instructions?: string
type?: string
metaData?: Record<string, string>
}

export interface ToolReference {
Expand All @@ -695,7 +696,6 @@ export interface Tool extends ToolDef {
id: string
type: typeof ToolType
toolMapping?: Record<string, ToolReference[]>
metaData?: Record<string, string>
localTools?: Record<string, string>
source?: SourceRef
workingDir?: string
Expand Down
20 changes: 18 additions & 2 deletions tests/gptscript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ describe("gptscript module", () => {

const inputs = [
"List the 3 largest of the Great Lakes by volume.",
"What is the volume of the second one in cubic miles?",
"What is the total area of the third one in square miles?"
"What is the volume of the second in the list in cubic miles?",
"What is the total area of the third in the list in square miles?"
]

const expectedOutputs = [
Expand Down Expand Up @@ -569,4 +569,20 @@ describe("gptscript module", () => {
expect(err).toEqual(undefined)
expect(out).toEqual("200")
}, 20000)

test("run parsed tool with metadata", async () => {
let err = undefined
let out = ""
let tools = await g.parse(path.join(__dirname, "fixtures", "parse-with-metadata.gpt"))

let run = await g.evaluate(tools[0])

try {
out = await run.text()
} catch (e) {
err = e
}
expect(err).toEqual(undefined)
expect(out).toEqual("200")
}, 20000)
})

0 comments on commit af7622e

Please sign in to comment.