{"id":26230945,"url":"https://github.com/madeindjs/mistral-js-tool-calls","last_synced_at":"2026-02-11T11:03:46.802Z","repository":{"id":275221276,"uuid":"925455440","full_name":"madeindjs/mistral-js-tool-calls","owner":"madeindjs","description":"Run JS function as Mistral Tools calls","archived":false,"fork":false,"pushed_at":"2025-01-31T23:28:28.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T01:37:00.433Z","etag":null,"topics":["jsdoc","llm","mistralai"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/mistral-js-tool-calls","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/madeindjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-31T23:09:41.000Z","updated_at":"2025-01-31T23:29:39.000Z","dependencies_parsed_at":"2025-01-31T23:31:35.991Z","dependency_job_id":"c3fda5a8-a2d5-493b-ac04-a015b4686753","html_url":"https://github.com/madeindjs/mistral-js-tool-calls","commit_stats":null,"previous_names":["madeindjs/mistral-js-tool-calls"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madeindjs%2Fmistral-js-tool-calls","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madeindjs%2Fmistral-js-tool-calls/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madeindjs%2Fmistral-js-tool-calls/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madeindjs%2Fmistral-js-tool-calls/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/madeindjs","download_url":"https://codeload.github.com/madeindjs/mistral-js-tool-calls/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248917051,"owners_count":21182918,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jsdoc","llm","mistralai"],"created_at":"2025-03-12T23:17:44.496Z","updated_at":"2026-02-11T11:03:46.795Z","avatar_url":"https://github.com/madeindjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Run JS function as Mistral Tools calls\n\nThis is a \"fun\" experiment to turn JavaScript [JSdoc](https://jsdoc.app/) comments as [Function calling](https://docs.mistral.ai/capabilities/function_calling/) using the Mistral client.\n\nIt's really handy to quickly prototype or automatise something like:\n\n- calling an external API\n- execute a script on the machine\n- etc..\n\n## Usage\n\n```sh\nnpm install mistral-js-tool-calls\n```\n\nLet's say you have a simple script which exposes two functions:\n\n```js\nimport { hostname } from \"node:os\";\nimport process from \"node:process\";\n\n/**\n * @description get the hostname\n * @returns {string} the hostname\n */\nexport function getHostname() {\n  return hostname();\n}\n\n/**\n * @description Get the environment variable\n * @param {string} name the name of the variable key\n * @returns {string} the environment variable value\n */\nexport function getEnvVariable(name) {\n  return process.env[name] ?? \"not found\";\n}\n```\n\n\u003e [!NOTE]\n\u003e The important part is the JSdoc comments. This library will extract them.\n\nThis library allow you to starts an interactive chat using the command\n\n```sh\nMISTRAL_API_KEY=\u003cyour-key\u003e mistral-js-tool-calls ./sample/os.js\n```\n\n```\n\u003e\u003e\u003e what is the environment variable named `HOME` and my hostname ?\n\nThe environment variable named `HOME` is `/home/alexandre` and your hostname is `thinkpad-t14`.\n```\n\nOr use it as library\n\n```js\nimport { Mistral } from \"@mistralai/mistralai\";\nimport { runInteractiveChat } from \"mistral-js-tool-calls\";\n\nconst client = new Mistral({ apiKey: \"\u003cyour-key\u003e\" });\n\nconst stream = await chatWithToolCall(\"./your-script.js\", client, {\n  model: \"open-mistral-7b\",\n  toolChoice: \"auto\",\n  temperature: 0.2,\n  messages: [\n    {\n      role: \"user\",\n      content:\n        \"what is the environment variable named `HOME` and my hostname ?\",\n    },\n  ],\n});\nfor await (const chunk of stream) process.stdout.write(chunk);\n```\n\n## Todos\n\n- [ ] use other providers\n- [ ] checks the order of parameters\n- [ ] throw if function uses a non-serializable object (function, class, etc...)\n- [ ] solve issue with entrypoint from CLI not starting by `./`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadeindjs%2Fmistral-js-tool-calls","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmadeindjs%2Fmistral-js-tool-calls","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadeindjs%2Fmistral-js-tool-calls/lists"}