Coder Social home page Coder Social logo

maldieve / math_app_langchain Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tahreemrasul/math_app_langchain

0.0 0.0 0.0 267 KB

A math application/chatbot to answer a user's arithmetic or reasoning based questions. Utilizes LangChain agents and tools. Frontend with Chainlit.

Python 100.00%

math_app_langchain's Introduction

Math App using LangChain Agents, OpenAI and Chainlit

You can read further here in this medium article.

Overview

This repo contains the code for a math app, Math Wiz, a custom chatbot that answers a user's arithmetic and reasoning questions. Chainlit is used for the web application portion. LLMs can be quite bad at general math questions, even the simplistic ones. This can be due to a variety of reasons, such as not having been trained on sufficient mathematical data, difficulty in carrying out numeric operations, as well as the fact that LLMs are text generators, and can struggle to come up with logic-based formulations. Having said that, they do contain a large corpus of trained dataset, and can offer superior text understanding and generation qualities. In this tutorial, we will demonstrate how the use of LangChain agents can significantly increase an LLM's performance when working with numerical or reasoning-based questions.

Application Process Diagram

LangChain Agents are comprised of one or more tools that can be used by the agent to get to the final decision. These tools can be online search, or chains carrying out modular tasks in an application flow. Below is the process diagram for the app designed in this tutorial: alt text for screen readers

For each user query, the agent uses the LLM to decide which tool to use. The flow of the agent can be visualized with this flow diagram: alt text for screen readers

Getting Started

Prerequisites

  • Python 3.8 or later
  • An OpenAI API key

Installation

  1. Clone the Repository
    git clone [email protected]:tahreemrasul/simple_chatbot_langchain.git
    cd ./simple_chatbot_langchain
    
  2. Set Up a Conda Environment (Recommended)
  • If you don't have Conda, install it first.
  • Create a new Conda environment:
    conda create -n math_assistant python=3.11
  • Activate the environment:
    conda activate math_assistant
    
  1. Install Dependencies
  • Install the required packages using the requirements.txt file:
    pip install -r requirements.txt
    
  1. Set Up Your OpenAI API Key
  • Create a .env file in the root directory of the project.
  • Add your OpenAI API key to the .env file:
    OPENAI_API_KEY='Your-OpenAI-API-Key-Here'
    

Usage

To run the Math Wiz app, simply execute the chatbot.py script using:

chainlit run chatbot.py -w --port 8000

This will run the application at http://localhost:8000

math_app_langchain's People

Contributors

tahreemrasul avatar

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.