diff --git a/docs/.DS_Store b/docs/.DS_Store index 3a7349a78..13e8234f7 100644 Binary files a/docs/.DS_Store and b/docs/.DS_Store differ diff --git a/docs/advanced/chatbot_agents/local.md b/docs/advanced/chatbot_agents/local.md new file mode 100644 index 000000000..3f122e5a4 --- /dev/null +++ b/docs/advanced/chatbot_agents/local.md @@ -0,0 +1,82 @@ +# Running and Testing Agents Locally + +You can run the Python function for your agent itself by writing a `main()` function, or you can call the [`testbench_prompts.py`](https://github.com/lambda-feedback/lambda-chat/blob/main/src/agents/utils/testbench_prompts.py) script that runs a similar pipeline to the `module.py`. + +```bash +python src/agents/utils/testbench_prompts.py +``` + +You can also use the `test_prompts.py` script to test the agents with example inputs from Lambda Feedback questions and synthetic conversations. +```bash +python src/agents/utils/test_prompts.py +``` + +## Testing using the Docker Image [:material-docker:](https://www.docker.com/) + +You can also build and run the docker pipeline for the agents. The chatbot agents are deployed onto a AWS Lambda serverless cloud function using the docker image. Hence, for final testing of your chatbots, we recommend completing those steps. + +#### Build the Docker Image + +To build the Docker image, run the following command in the root folder of the project (where the Dockerfile is located): + +```bash +docker build -t llm_chat . +``` + +### Running the Docker Image + +To run the Docker image, use the following command: + +#### Without .env file: + +```bash +docker run -e OPENAI_API_KEY={your key} -e OPENAI_MODEL={your LLM chosen model name} -p 8080:8080 llm_chat +``` + +#### With container name (for interaction, e.g. copying file from inside the docker container): + +```bash +docker run --env-file .env -it --name my-lambda-container -p 8080:8080 llm_chat +``` + +This will start the evaluation function and expose it on port `8080` and it will be open to be curl: + +```bash +curl --location 'http://localhost:8080/2015-03-31/functions/function/invocations' --header 'Content-Type: application/json' --data '{"message":"hi","params":{"conversation_id":"12345Test","conversation_history": [{"type":"user","content":"hi"}]}}' +``` + +### Call Docker Container From Postman + +POST URL: + +```bash +http://localhost:8080/2015-03-31/functions/function/invocations +``` + +Body: + +```JSON +{ + "message":"hi", + "params":{ + "conversation_id":"12345Test", + "conversation_history": [{"type":"user","content":"hi"}] + } +} +``` + +Body with optional Params: +```JSON +{ + "message":"hi", + "params":{ + "conversation_id":"12345Test", + "conversation_history":[{"type":"user","content":"hi"}], + "summary":" ", + "conversational_style":" ", + "question_response_details": "", + "include_test_data": true, + "agent_type": {agent_name} + } +} +``` \ No newline at end of file diff --git a/docs/advanced/chatbot_agents/quickstart.md b/docs/advanced/chatbot_agents/quickstart.md new file mode 100644 index 000000000..72b2c78d0 --- /dev/null +++ b/docs/advanced/chatbot_agents/quickstart.md @@ -0,0 +1,70 @@ +# Developing Chat Agents: Getting Started + +## What is a Chat Agent? + +It's a function which calls Large Language Models (LLMs) to respond to the student's messages given contxtual data: + +- question data +- user data such as past responses to the problem + Chatbot Agents capture and automate the process of assisting students during their learning process when outside of classroom. + +## Getting Setup for Development + +1. Get the code on your local machine (Using github desktop or the `git` cli) + + - For new functions: clone the main repo for [lambda-chat](https://github.com/lambda-feedback/lambda-chat) and create a new branch. Then go under `scr/agents` and copy the `base_agent` folder. + + - For existing functions: please make your changes on a new separate branch + +2. _If you are creating a new chatbot agent_, you'll need to set it's name as the folder name in `scr/agents` and its corresponding files. +3. You are now ready to start making changes and implementing features by editing each of the three main function-logic files: + + 1. **`scr/agents/{base_agent}/{base}_agent.py`**: This file contains the main LLM pipeline using [LangGraph](https://langchain-ai.github.io/langgraph/) and [LangChain](https://python.langchain.com/docs/introduction/). + + - the agent expects the following inputs when it being called: + + Body with necessary Params: + + ```JSON + { + "message":"hi", + "params":{ + "conversation_id":"12345Test", + "conversation_history": [{"type":"user","content":"hi"}] + } + } + ``` + + Body with optional Params: + + ```JSON + { + "message":"hi", + "params":{ + "conversation_id":"12345Test", + "conversation_history":[{"type":"user","content":"hi"}], + "summary":" ", + "conversational_style":" ", + "question_response_details": "", + "include_test_data": true, + "agent_type": {agent_name} + } + } + ``` + + 2. **`scr/agents/{base_agent}/{base}_prompts.py`**: This is where you can write the system prompts that describe how your AI Assistant should behave and respond to the user. + + 3. Make sure to add your agent `invoke()` function to the `module.py` file. + + 4. Please add a `README.md` file to describe the use and behaviour of your agent. + +4. Changes can be tested locally by running the pipeline tests using: + ```bash + pytest src/module_test.py + ``` + [Running and Testing Agents Locally](local.md){ .md-button } + + +5. Merge commits into any branch (except main) will trigger the `dev.yml` workflow, which will build the docker image, push it to a shared `dev` ECR repository to make the function available from the `dev` and `localhost` client app. + +6. In order to make your new chatbot available on the LambdaFeedback platform, you will have to get in contact with the ADMINS on the platform. diff --git a/docs/advanced/index.md b/docs/advanced/index.md index 16096fd9d..ec81ab5bb 100644 --- a/docs/advanced/index.md +++ b/docs/advanced/index.md @@ -14,6 +14,12 @@ Response areas are components in the frontend where student users can enter a re [Response areas - overview](response_areas/overview.md){ .md-button .md-button--primary} +## AI Chatbot Agents + +Chatbot agents are AI Assistants that students can chat with to ask for help or further explanations regarding the Question that they are working on. Each Agent has its own personality and approach to assisting the students. + +[Chatbot Agents - Quickstart guide](chatbot_agents/quickstart.md){ .md-button .md-button--primary} + ## System Architecture - Technologies diff --git a/docs/student/answering_questions.md b/docs/student/answering_questions.md index 74bc61035..6fd75d695 100644 --- a/docs/student/answering_questions.md +++ b/docs/student/answering_questions.md @@ -12,7 +12,7 @@ If there is no response area (e.g. for a "show that..." question), you can manua If you are stuck, you can view worked solutions using the "Worked Solutions" option on the bottom ribbon. The steps in the solution are revealed step-by-step, so you should avoid the temptation to look at the whole solution at once, and try to complete as much as possible -independantly. +independently. ![The worked solutions area](images/worked_solutions.png) diff --git a/docs/student/getting_started_student.md b/docs/student/getting_started_student.md index 515677456..eb5e0cc96 100644 --- a/docs/student/getting_started_student.md +++ b/docs/student/getting_started_student.md @@ -33,3 +33,17 @@ See the [Answering Questions](answering_questions.md) page for more help with an ![The "Mark as done" box on the question page](images/mark_as_done.png) +### Using the Workspace + +The Workspace provides you with various functionalities to assist you during your learning process: +1. #### Canvas: +A pane where you can write down your thought process and notes for the previewed question (handwriting, sticky notes & text). + +![Canvas Interface](images/canvas_interface.png) + +2. #### Chat: +A chat interface connecting you with helpful AI Chatbots to discuss any questions you have on the current topic you are working on. + +![Chat Interface](images/chat_interface.png) + +Your edits and progress in the Workspace are saved per each Question you preview. So, you will be able to view your old edits for the Question you are currently on. diff --git a/docs/student/image.png b/docs/student/image.png deleted file mode 100644 index 30a8c1d10..000000000 Binary files a/docs/student/image.png and /dev/null differ diff --git a/docs/student/images/canvas_interface.png b/docs/student/images/canvas_interface.png new file mode 100644 index 000000000..bebe4e403 Binary files /dev/null and b/docs/student/images/canvas_interface.png differ diff --git a/docs/student/images/chat_interface.png b/docs/student/images/chat_interface.png new file mode 100644 index 000000000..e5b484dbc Binary files /dev/null and b/docs/student/images/chat_interface.png differ diff --git a/docs/student/images/question_interface.png b/docs/student/images/question_interface.png index 1d2aecfae..086644cf5 100644 Binary files a/docs/student/images/question_interface.png and b/docs/student/images/question_interface.png differ diff --git a/docs/terminology.md b/docs/terminology.md index edee75cc4..045c5b6cb 100644 --- a/docs/terminology.md +++ b/docs/terminology.md @@ -53,3 +53,7 @@ From the perspective of Lambda Feedback, a teacher is someone who creates and ma The stages of working that lead to a final answer. It may be split into multiple steps which the student can reveal sequentially. This section lies within the "Help" panel which appears upon clicking on the "Help" button. This is an optional section, and so does not have to be included in any question. + +### Workspace + +On the Question page, the students has access to their own workspace tab. Here they can find the "Canvas", for handwriting notes, and the "Chat", for conversing with an AI Chatbot on the question materials. \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index b9d54692e..17e895b3e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -60,6 +60,8 @@ nav: - Advanced: - "advanced/index.md" + - Response Areas: + - Overview: "advanced/response_areas/overview.md" - Evaluation Functions: - Quickstart Guide: "advanced/evaluation_functions/quickstart.md" - General Specification: "advanced/evaluation_functions/specification.md" @@ -69,8 +71,9 @@ nav: - Deployed Functions: - "advanced/evaluation_functions/index.md" - Alternate Function Languages: "advanced/evaluation_functions/alternate_languages.md" - - Response Areas: - - Overview: "advanced/response_areas/overview.md" + - Chat agents: + - Quickstart: "advanced/chatbot_agents/quickstart.md" + - Testing Functions Locally: "advanced/chatbot_agents/local.md" # Configuration theme: @@ -88,6 +91,7 @@ theme: - navigation.tabs - navigation.tabs.sticky - content.action.edit + - content.code.copy palette: - media: "(prefers-color-scheme: light)" scheme: default