{"id":29299741,"url":"https://github.com/mermade/bingchain","last_synced_at":"2025-07-06T19:41:07.258Z","repository":{"id":200304758,"uuid":"698793618","full_name":"Mermade/bingchain","owner":"Mermade","description":"Capable Langchain/AutoGPT alternative in ~350 lines of core code","archived":false,"fork":false,"pushed_at":"2024-01-08T16:33:51.000Z","size":5087,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-14T23:16:41.025Z","etag":null,"topics":["ai","chatgpt","llm"],"latest_commit_sha":null,"homepage":"https://mermade.org.uk/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mermade.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-10-01T01:44:32.000Z","updated_at":"2024-03-26T10:19:22.000Z","dependencies_parsed_at":"2023-10-16T14:38:14.283Z","dependency_job_id":null,"html_url":"https://github.com/Mermade/bingchain","commit_stats":null,"previous_names":["mermade/bingchain"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Mermade/bingchain","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mermade%2Fbingchain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mermade%2Fbingchain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mermade%2Fbingchain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mermade%2Fbingchain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mermade","download_url":"https://codeload.github.com/Mermade/bingchain/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mermade%2Fbingchain/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263962473,"owners_count":23536450,"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":["ai","chatgpt","llm"],"created_at":"2025-07-06T19:41:00.194Z","updated_at":"2025-07-06T19:41:07.251Z","avatar_url":"https://github.com/Mermade.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🕵️🔗 BingChain\n\nThis is an evolution of [langchain-mini](https://github.com/ColinEberhardt/langchain-mini), a very simple re-implementation of [LangChain](https://github.com/hwchase17/langchain), in ~350 lines of core code. In essence, it is a multi-model LLM-powered chat application that is able to use tools (Microsoft **Bing** search, URL retrieval, API plugin installation, API calls, a Javascript sandbox, JsFiddle creation, image and video preview, and a scientific calculator, as well as meta-tools such as `list`, `disable`, `reset` and `debug`) in order to build a **chain** of thought to hold conversations and answer questions.\n\nHere's an example:\n\n~~~\nQ: What is the world record for solving a rubiks cube?\nThe world record for solving a Rubik's Cube is 4.69 seconds, held by Yiheng Wang (China).\nQ: Can a robot solve it faster?\nThe fastest time a robot has solved a Rubik's Cube is 0.637 seconds.\nQ: Who made this robot?\nInfineon created the robot that solved a Rubik's Cube in 0.637 seconds.\nQ: What time would an average human expect for solving?\nIt takes the average person about three hours to solve a Rubik's cube for the first time.\n~~~\n\nThis is not intended to be a replacement for LangChain, which has many alternative and composable building blocks, instead it was built to demonstrate the power of assembling a set of tools (such as API calling and Javascript execution). If you're interested in how LangChain, and similar tools work, this is a very good starting point.\n\n## Running / developing\n\nInstall dependencies, and run (with node \u003e= v18):\n\n~~~\n% npm install\n~~~\n\nTo display videos in the terminal, you will need to install `ffmpeg`.\n\nYou'll need to have an OpenAI API key, and optionally a Bing Search API key. These can be supplied to the application via a `.env` file:\n\n```shell\nOPENAI_API_KEY=\"...\"\nBING_API_KEY=\"...\"\nMODEL=gpt-4\nTOKEN_LIMIT=32768\nTEMPERATURE=0.25\nRESPONSE_LIMIT=512\nPORT=1337\nGUI=1\n#LANG=Ukrainian\n#DEBUG=2\n#SEED_QUERIES=1\n#PROMPT_OVERRIDE=Riddle me this! ${question}\n```\n\nYou can also set `PROVIDER=anthropic` (with a relevant `ANTHROPIC_API_KEY`, `MODEL` and `TOKEN_LIMIT`) to use an alternative LLM/API provider.\n\nSet the token limit to the advertised limit of the model you are using, so 32768 for `gpt-4`, 4096 for `text-davinci-003` and 2048 for `text-curie-001`.\n\nThe clever part is the default initial prompt, which is held in [`prompt.txt`](https://raw.githubusercontent.com/postman-open-technologies/bingchain/main/prompt.txt), unless overridden by the `PROMPT_OVERRIDE` environment variable.\n\nExample prompts and responses to show how the various built-in tools work can be found in the [`examples`](https://github.com/postman-open-technologies/bingchain/tree/main/examples) directory. The tools themselves are defined in [`lib/tools.mjs`](https://github.com/postman-open-technologies/bingchain/tree/main/lib/tools.mjs), including the `description` properties which act as further prompts to the LLM to suggest when and how the tools should be used.\n\nThere are a few Javascript and CSS files scattered about from [jsfiddle.net](https://jsfiddle.net/) to make the `savetext`, `savehtml` and `savecode` tools work locally.\n\n**Note**: to enable the Javascript sandbox, you must pass the option `--experimental-vm-modules` to Node.js. The included `go.sh` script sets the Node.js recommended options.\n\n## Start-up\n\nThe application will display the built-in tools as it initialises them. Tool names followed by [1] are disabled by default for security reasons (i.e. they may access files on your local filesystem or your environment variables). You can enable them by typing `enable [toolname]` at the prompt. Tool names followed by [2] are disabled becuase you do not have the requisite API key in your environment or your version of Node.js does not support the required features.\n\n## Example dialogue\n\nYou can now run the chain:\n\n```repl\n% ./go.sh\nHow can I help? \u003e what was the name of the first woman in space?\n```\n\n* I need to search for the name of the first woman in space.\n* *Action*: `search`\n* *Action Input*: `first woman in space name`\n\nCalling `search` with `first woman in space name`\n\n1. **Valentina Tereshkova - First Woman in Space - Biography**\n2. **Valentina Tereshkova: First Woman in Space | Space**\n3. **The First Woman in Space: Valentina Tereshkova - ThoughtCo**\n\n* *Thought*: I now know the final answer.\n* *Final Answer*: The name of the first woman in space is Valentina Tereshkova.\n* **The name of the first woman in space is Valentina Tereshkova.**\n\n### Exiting the chain / vi mode\n\n* You can use `vi`/`vim`-like commands to exit, such as `:q` or you can Ctrl-C twice to exit.\n* You can use `:set` to query all environment variables or `:set [variable]=[value]` to temporarily amend the current environment.\n\n## Authors\n\n* [Mike Ralphson](https://github.com/MikeRalphson)\n* [Gbadeyboh Bello](https://github.com/Gbahdeyboh)\n* [Colin Eberhardt](https://github.com/ColinEberhardt)\n\n## Future work planned\n\n* Ideas and PRs gratefully received.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmermade%2Fbingchain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmermade%2Fbingchain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmermade%2Fbingchain/lists"}