Skip to content

Commit

Permalink
✨ enhance: add context logging and clarify math expression
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Oct 18, 2024
1 parent 2d4e1ab commit 8bc9baf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions docs/src/content/docs/reference/scripts/system.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1918,14 +1918,17 @@ defTool(
properties: {
expression: {
type: "string",
description: "Math expression to evaluate using mathjs format.",
description:
"Math expression to evaluate using mathjs format. Use ^ for power operator.",
},
},
required: ["expression"],
},
async (args) => {
const { expression } = args
return "" + ((await parsers.math(expression)) ?? "?")
const { context, expression } = args
const res = String((await parsers.math(expression)) ?? "?")
context.log(`math: ${expression} => ${res}`)
return res
}
)
Expand Down
9 changes: 6 additions & 3 deletions packages/core/src/genaisrc/system.math.genai.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ defTool(
properties: {
expression: {
type: "string",
description: "Math expression to evaluate using mathjs format.",
description:
"Math expression to evaluate using mathjs format. Use ^ for power operator.",
},
},
required: ["expression"],
},
async (args) => {
const { expression } = args
return "" + ((await parsers.math(expression)) ?? "?")
const { context, expression } = args
const res = String((await parsers.math(expression)) ?? "?")
context.log(`math: ${expression} => ${res}`)
return res
}
)

0 comments on commit 8bc9baf

Please sign in to comment.