@botbotgo/better-call 0.1.30 → 0.1.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/demo.mjs +7 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botbotgo/better-call",
3
- "version": "0.1.30",
3
+ "version": "0.1.32",
4
4
  "description": "Small-model tool-call reliability layer for LangChain and custom agent runtimes.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
package/scripts/demo.mjs CHANGED
@@ -37,7 +37,7 @@ const stockQuote = {
37
37
  },
38
38
  };
39
39
 
40
- const badArgs = { symbol: "Apple", market: "NASDAQ" };
40
+ const mismatchedArgs = { symbol: "Apple", market: "NASDAQ" };
41
41
 
42
42
  const wrappedTools = betterTools([stockQuote], {
43
43
  userInput: "Get Apple stock in the US market.",
@@ -57,18 +57,18 @@ const wrappedStockQuote = wrappedTools[0];
57
57
 
58
58
  let wrappedOutput;
59
59
  try {
60
- wrappedOutput = await wrappedStockQuote.invoke(badArgs);
60
+ wrappedOutput = await wrappedStockQuote.invoke(mismatchedArgs);
61
61
  } catch (error) {
62
62
  exitWithError("wrapped stock_quote invocation", error);
63
63
  }
64
64
 
65
- let reliableResult;
65
+ let reliableResult = null;
66
66
  try {
67
67
  reliableResult = await reliableToolCalls({
68
68
  userInput: "Get Apple stock in the US market.",
69
69
  tools: [stockQuote],
70
70
  // The tool name is intentionally wrong to demonstrate repair to stock_quote.
71
- calls: [{ tool: "stock_price", args: badArgs }],
71
+ calls: [{ tool: "stock_price", args: mismatchedArgs }],
72
72
  repair() {
73
73
  return [{ tool: "stock_quote", args: { ticker: "AAPL", market: "US" } }];
74
74
  },
@@ -109,17 +109,15 @@ try {
109
109
  };
110
110
  }
111
111
 
112
- const repairedCall = reliableResult && Array.isArray(reliableResult.calls) && reliableResult.calls.length > 0
113
- ? reliableResult.calls[0]
114
- : null;
112
+ const repairedCall = reliableResult?.calls?.[0] ?? null;
115
113
 
116
114
  const report = {
117
115
  wrappedTool: {
118
- before: badArgs,
116
+ before: mismatchedArgs,
119
117
  after: wrappedOutput,
120
118
  },
121
119
  reliableToolCalls: {
122
- before: { tool: "stock_price", args: badArgs },
120
+ before: { tool: "stock_price", args: mismatchedArgs },
123
121
  repaired: repairedCall,
124
122
  diagnostics: reliableResult?.diagnostics ?? null,
125
123
  },