@botbotgo/better-call 0.1.26 → 0.1.27

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.
@@ -12,7 +12,7 @@ LLM tool calling has a boring failure mode that shows up constantly with small m
12
12
 
13
13
  The model knows a tool is needed, but the actual call is not executable.
14
14
 
15
- It may pick a near-miss tool name, send `symbol` instead of `ticker`, use an enum value the schema rejects, include extra fields, or emit raw tool-call-shaped text. If your runtime sends that straight to a real tool, the best case is a failed request. The worse case is the wrong operation reaching production code.
15
+ It may pick a near-miss tool name, send `symbol` instead of `ticker`, use an enum value the schema rejects, include extra fields, or emit raw tool-call-shaped text. If your runtime sends that straight to a real tool, the best case is a failed request. The worst case is the wrong operation reaching production code.
16
16
 
17
17
  BetterCall is a small TypeScript reliability layer for that boundary.
18
18
 
@@ -10,10 +10,10 @@ const result = await reliableToolCalls({
10
10
  tools,
11
11
  calls,
12
12
  repair: async ({ userInput, tools, calls, issues }) => {
13
- const response = await fetch(`${baseUrl}/chat/completions`, {
13
+ const response = await fetch(`${baseUrl}/v1/chat/completions`, {
14
14
  method: "POST",
15
15
  headers: {
16
- "authorization": `Bearer ${apiKey}`,
16
+ "Authorization": `Bearer ${apiKey}`,
17
17
  "content-type": "application/json",
18
18
  },
19
19
  body: JSON.stringify({
@@ -33,5 +33,5 @@ The Ollama and OpenAI-compatible examples expect local model endpoints:
33
33
 
34
34
  ```bash
35
35
  OLLAMA_BASE_URL=http://127.0.0.1:11434 OLLAMA_MODEL=granite4.1:3b node examples/ollama-small-model.mjs
36
- OPENAI_BASE_URL=http://127.0.0.1:8000/v1 OPENAI_MODEL=local-model node examples/adapters/openai-compatible-repair.mjs
36
+ OPENAI_BASE_URL=http://127.0.0.1:8000 OPENAI_MODEL=local-model node examples/adapters/openai-compatible-repair.mjs
37
37
  ```
@@ -1,6 +1,6 @@
1
1
  import { reliableToolCalls } from "../../dist/index.js";
2
2
 
3
- const baseUrl = process.env.OPENAI_BASE_URL ?? "http://127.0.0.1:8000/v1";
3
+ const baseUrl = process.env.OPENAI_BASE_URL ?? "http://127.0.0.1:8000";
4
4
  const model = process.env.OPENAI_MODEL ?? "local-model";
5
5
  const apiKey = process.env.OPENAI_API_KEY ?? "not-needed-for-local";
6
6
 
@@ -23,10 +23,10 @@ const result = await reliableToolCalls({
23
23
  tools,
24
24
  calls: [{ tool: "stock_price", args: { symbol: "Apple", market: "NASDAQ" } }],
25
25
  repair: async ({ userInput, tools, calls, issues }) => {
26
- const response = await fetch(`${baseUrl}/chat/completions`, {
26
+ const response = await fetch(`${baseUrl}/v1/chat/completions`, {
27
27
  method: "POST",
28
28
  headers: {
29
- "authorization": `Bearer ${apiKey}`,
29
+ "Authorization": `Bearer ${apiKey}`,
30
30
  "content-type": "application/json",
31
31
  },
32
32
  body: JSON.stringify({
@@ -17,12 +17,12 @@ const tools = [{
17
17
  },
18
18
  }];
19
19
 
20
- const badCall = { tool: "stock_price", args: { symbol: "Apple", market: "NASDAQ" } };
20
+ const invalidToolCall = { tool: "stock_price", args: { symbol: "Apple", market: "NASDAQ" } };
21
21
 
22
22
  const result = await reliableToolCalls({
23
23
  userInput: "Get Apple stock in the US market.",
24
24
  tools,
25
- calls: [badCall],
25
+ calls: [invalidToolCall],
26
26
  repair: async ({ userInput, tools, calls, issues }) => {
27
27
  const prompt = [
28
28
  "Return corrected JSON only as {\"calls\":[{\"tool\":\"name\",\"args\":{}}]}.",
@@ -43,4 +43,4 @@ const result = await reliableToolCalls({
43
43
  },
44
44
  });
45
45
 
46
- console.log(JSON.stringify({ model, badCall, result }, null, 2));
46
+ console.log(JSON.stringify({ model, invalidToolCall, result }, null, 2));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botbotgo/better-call",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
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
@@ -34,6 +34,7 @@ const wrappedOutput = await wrappedStockQuote.invoke(badArgs);
34
34
  const reliableResult = await reliableToolCalls({
35
35
  userInput: "Get Apple stock in the US market.",
36
36
  tools: [stockQuote],
37
+ // The tool name is intentionally wrong to demonstrate repair to stock_quote.
37
38
  calls: [{ tool: "stock_price", args: badArgs }],
38
39
  repair() {
39
40
  return [{ tool: "stock_quote", args: { ticker: "AAPL", market: "US" } }];