Skip to content

fix: put metadata on tool def #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
})