Giter Site home page Giter Site logo

langchain-mini's Introduction

๐Ÿฆœ๏ธ๐Ÿ”— LangChain-mini

This is a very simple re-implementation of LangChain, in ~100 lines of code. In essence, it is an LLM (GPT-3.5) powered chat application that is able to use tools (Google search and a calculator) in order to hold conversations and answer questions.

Here's an example:

Q: What is the world record for solving a rubiks cube?
The world record for solving a Rubik's Cube is 4.69 seconds, held by Yiheng Wang (China).
Q: Can a robot solve it faster?
The fastest time a robot has solved a Rubik's Cube is 0.637 seconds.
Q: Who made this robot?
Infineon created the robot that solved a Rubik's Cube in 0.637 seconds.
Q: What time would an average human expect for solving?
It takes the average person about three hours to solve a Rubik's cube for the first time.

This is not intended to be a replacement for LangChain, instead it was built for fun and educational purposes. If you're interested in how LangChain, and similar tools work, this is a good starting point.

For more information about this project, read the accompanying blogpost - Re-implementing LangChain in 100 lines of code

Running / developing

Install dependencies, and run (with node >= v18):

% npm install

You'll need to have both an OpenAI and SerpApi keys. These can be supplied to the application via a .env file:

OPENAI_API_KEY="..."
SERPAPI_API_KEY="..."

You can now run the chain:

% node index.mjs
How can I help? what was the name of the first man on the moon?
Neil Armstrong

langchain-mini's People

Contributors

adityadeshpande09 avatar colineberhardt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

langchain-mini's Issues

Add License

Add a license file for the project.
Can I work on this.

Error- Cannot read properties of undefined (reading '0')

Hi! Thank you very much for your work.
Please tell me which way to look. When I start, I get this error, I see the problem, but I can't figure out what to do.

How can I help? Who is Neil Armstrong?
file:///User/GitHub/langchain-mini/index.mjs:59
    .then((res) => res.choices[0].text)
                              ^

TypeError: Cannot read properties of undefined (reading '0')
    at file:///User/GitHub/langchain-mini/index.mjs:59:31
    at process.process Ticks And Rejection (node:internal/process/task_queues:95:5)
    at asynccomplete Prompt (file:///User/GitHub/langchain-mini/index.mjs:43:3)
    at async answer Question (file:///User/GitHub/langchain-mini/index.mjs:77:22)
    at async file:///User/GitHub/langchain-mini/index.mjs:109:18

Node.js v18.15.0

The line index.mjs:59 says .then((res) => res.choices[0].text)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.