Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified docs/.DS_Store
Binary file not shown.
82 changes: 82 additions & 0 deletions docs/advanced/chatbot_agents/local.md
Original file line number Diff line number Diff line change
@@ -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}
}
}
```
70 changes: 70 additions & 0 deletions docs/advanced/chatbot_agents/quickstart.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 6 additions & 0 deletions docs/advanced/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/student/answering_questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 14 additions & 0 deletions docs/student/getting_started_student.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Binary file removed docs/student/image.png
Binary file not shown.
Binary file added docs/student/images/canvas_interface.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/student/images/chat_interface.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/student/images/question_interface.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions docs/terminology.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
8 changes: 6 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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:
Expand All @@ -88,6 +91,7 @@ theme:
- navigation.tabs
- navigation.tabs.sticky
- content.action.edit
- content.code.copy
palette:
- media: "(prefers-color-scheme: light)"
scheme: default
Expand Down
Loading