mirror of
https://github.com/langchain-ai/langchain-teacher.git
synced 2026-07-01 15:19:06 -04:00
readme and prompt changes
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
OPENAI_API_KEY=
|
||||
LANGCHAIN_ENDPOINT=https://api.smith.langchain.com
|
||||
LANGCHAIN_API_KEY=
|
||||
LANGCHAIN_TRACING_V2=true
|
||||
LANGCHAIN_PROJECT=
|
||||
@@ -1 +1,68 @@
|
||||
# langchain-teacher
|
||||
|
||||
# LangChain-Teacher
|
||||
|
||||
## Description
|
||||
|
||||
LangChain-Teacher is designed to facilitate interactive learning of LangChain, allowing users to engage with the LangChain platform through a chat-based learning interface. The app provides two teaching styles: Instructional, which provides step-by-step instructions, and Interactive lesson with questions, which prompts users with questions to assess their understanding.
|
||||
|
||||
## 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
|
||||
```
|
||||
|
||||
## Repository Details
|
||||
|
||||
- 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.
|
||||
|
||||
- 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 and to detect prompt injections.
|
||||
|
||||
## Contributions
|
||||
|
||||
There are numerous ways to enhance the teaching style and overall functionality of the app. Contributions and suggestions for improvements are welcome. Feel free to contribute by creating pull requests or raising issues.
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the [MIT License](LICENSE).
|
||||
|
||||
|
||||
|
||||
+13
-4
@@ -17,7 +17,12 @@ def load_prompt(content):
|
||||
This is an interactive lesson - do not lecture them, but rather engage and guide them along!
|
||||
-----------------
|
||||
|
||||
{content}""".format(content=content)
|
||||
{content}
|
||||
|
||||
-----------------
|
||||
End of Content.
|
||||
|
||||
Now remember short response with only 1 code snippet per message.""".format(content=content)
|
||||
|
||||
prompt_template = ChatPromptTemplate(messages = [
|
||||
SystemMessage(content=template),
|
||||
@@ -43,11 +48,15 @@ def load_prompt_with_questions(content):
|
||||
Only include 1 code snippet per message - make sure they can run that before giving them any more. \
|
||||
Make sure they fully understand that before moving on to the next. \
|
||||
This is an interactive lesson - do not lecture them, but rather engage and guide them along!\
|
||||
Ask them many questions at each step and grade their response, only proceed if their understanding \
|
||||
is above 70%
|
||||
-----------------
|
||||
|
||||
{content}""".format(content=content)
|
||||
{content}
|
||||
|
||||
|
||||
-----------------
|
||||
End of Content.
|
||||
|
||||
Now remember short response with only 1 code snippet per message and ask question to test users knowledge right away.""".format(content=content)
|
||||
|
||||
prompt_template = ChatPromptTemplate(messages = [
|
||||
SystemMessage(content=template),
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ lesson_type = st.sidebar.radio("Select Lesson Type", ["Instructions based lesson
|
||||
if st.session_state.get("current_lesson") != lesson_selection or st.session_state.get("current_lesson_type") != lesson_type:
|
||||
st.session_state["current_lesson"] = lesson_selection
|
||||
st.session_state["current_lesson_type"] = lesson_type
|
||||
st.session_state["messages"] = [AIMessage(content="Welcome! This short course will help you get started with LangChain.")]
|
||||
st.session_state["messages"] = [AIMessage(content="Welcome! This short course will help you get started with LangChain. Let me know when you're all set to jump in!")]
|
||||
|
||||
# Display lesson name and description
|
||||
st.markdown(f"**{lesson_selection}**")
|
||||
|
||||
Reference in New Issue
Block a user