Giter Club home page Giter Club logo

langchain-teacher's Introduction

LangChain-Teacher

app screenshot

Description

LangChain-Teacher's goal is to facilitate interactive learning of LangChain, enabling users to begin with the Python-based LangChain through a chat-based learning interface. The app offers two teaching styles: Instructional, which provides step-by-step instructions, and Interactive lessons with questions, which prompts users with questions to assess their understanding.

The hosted version of the app is on Streamlit Cloud at lang-teacher.streamlit.app

How Does This Work?

The core of the teaching process is driven by the prompts defined in get_prompt.py. This module creates lessons based on the content available in the lc_guides folder, where lessons are stored as .txt files.

To give a bit more context:

  • The prompt, combined with the lesson content from the .txt file, is sent to a Language Learning Model (LLM) to assist in generating bite-sized lessons.

  • The chat memory helps LLM retain information about previous instructions and add new ones to the conversation.

  • This showcases the power of prompt templates and how prompt engineering could be used in the development of LLM applications.

Getting Started

This Streamlit app guides users through lessons using a chat-based interface. To get started, follow these steps:

Prerequisites

  • Python 3.10 or higher

Installation

  1. Clone the repository from GitHub or create a GitHub Codespace:

    git clone https://github.com/hwchase17/langchain-teacher.git
    

    Change directory to the langchain-teacher directory

    cd langchain-teacher
    
  2. Install the required dependencies listed in requirements.txt:

    pip install -r requirements.txt
    
  3. Create a .env file in the root directory and add the following environment variables:

    OPENAI_API_KEY=
    LANGCHAIN_ENDPOINT=
    LANGCHAIN_API_KEY=
    LANGCHAIN_TRACING_V2=
    LANGCHAIN_PROJECT=
    

    An example .env file is provided as .env-example. If you're not using LangSmith, you only need to set the OPENAI_API_KEY variable.

  4. Run the Streamlit app using the command:

    streamlit run lc_main.py
    

    If using dotenv to manage environment variables, use the following command:

    dotenv streamlit run lc_main.py
    

Additional Files and Branches

  • The initial version of the app used a getting started guide at guide.txt together with the main.py file to run the streamlit app. You can also run the initial version of the app using the command:

     streamlit run main.py
    
  • There is also a tutor for LangChain expression language with lesson files in the lcel folder and the lcel.py file to run the streamlit app.

  • The supervisor-model branch in this repository implements a SequentialChain to supervise responses from students and teachers. This approach aims to ensure that questions are on-topic by the students and that the responses are accordingly as well by the teacher model.

Future Work

  • Integration with LangSmith Hub: Integrate prompts directly into the LangSmith Hub.

  • Expanding Lesson Library: Continuously add new lessons to create a comprehensive learning resource.

  • Token Usage Improvement: Currently the prompt sent to the LLM is quite large as it takes the prompt and the lesson. Could be improved further.

Contributions

Please feel free to add more lessons/examples/use cases. We would love for langchain-teacher to be the first stop for any new learner. You can contribute by creating pull requests or raising issues.

License

This project is licensed under the MIT License.

langchain-teacher's People

Contributors

hwchase17 avatar misbahsy avatar codiprod 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.