# Typescript Sample Code for Function Calling is wrong

**URL:** <https://community.openai.com/t/typescript-sample-code-for-function-calling-is-wrong/1368645>\
**Category:** Documentation\
**Tags:** function-calling\
**Created:** [December 7, 2025, 6:44pm UTC](https://community.openai.com/t/typescript-sample-code-for-function-calling-is-wrong/1368645 "2025-12-07T18:44:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![goyalkavya](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/goyalkavya/32/568642_2.png) [@goyalkavya](https://community.openai.com/u/goyalkavya)\
**Post date:** [December 7, 2025, 6:44pm UTC](https://community.openai.com/t/typescript-sample-code-for-function-calling-is-wrong/1368645/1 "2025-12-07T18:44:49Z")

</div>

The typescript sample code present [here](https://platform.openai.com/docs/guides/function-calling/) is wrong,

The input defined and given as message to the LLM calls is named as `input`. However, the results of the tool-execution are added to an undefined variable named `input_list`

 ![Screenshot 2025-12-08 at 12.14.37 AM](https://us1.discourse-cdn.com/openai1/original/4X/1/e/8/1e89531c943ac082e542585e258ffeafd9b3502b.jpeg)

 ![Screenshot 2025-12-08 at 12.13.48 AM](https://us1.discourse-cdn.com/openai1/original/4X/9/4/3/9432fcc947fc6997212773b48b46da06a5f7ff81.jpeg)

---

<div class="post-metadata">

**Author:** ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/766292_2.png) [@\_j](https://community.openai.com/u/_j)\
**Post date:** [December 7, 2025, 7:11pm UTC](https://community.openai.com/t/typescript-sample-code-for-function-calling-is-wrong/1368645/2 "2025-12-07T19:11:24Z")

</div>

“Find the undefined variables being used, AI!”

* * *

> Here are the identifiers that are **used but never defined** in your Node.js code:
> 
> 1. **`get_horoscope`**
> 
> 2. **`input_list`**
> 
> 3. **`json`**
> 
> Wrap-up: the undefined variable usages are `get_horoscope`, `input_list`, and `json`; they should correspond to your defined `getHoroscope`, `input`, and `JSON.stringify` respectively.

* * *

Or another smart AI provider:

> Based on a strict analysis of the provided Node.js code, there are **3 undefined variables**.
> 
> The code suffers from “language confusion,” mixing Python syntax and naming conventions into JavaScript.
> 
> ### 1. `get_horoscope`
> 
> - **Location:** Line 43
> - **Code:** `const horoscope = get_horoscope(JSON.parse(item.arguments))`
> - **Reason:** The function defined on line 23 is named **`getHoroscope`** (camelCase). The code attempts to call `get_horoscope` (snake\_case), which has not been defined.
> 
> ### 2. `input_list`
> 
> - **Location:** Line 46
> - **Code:** `input_list.push({`
> - **Reason:** The array defined on line 28 is named **`input`**. The variable `input_list` does not exist.
> 
> ### 3. `json`
> 
> - **Location:** Line 49
> - **Code:** `output: json.dumps({`
> - **Reason:** In JavaScript, the global object for JSON handling is **`JSON`** (uppercase). `json` (lowercase) is undefined. Additionally, `.dumps` is a Python method; JavaScript uses `.stringify`, though `json` is the specific undefined variable here.
