Skip to content

Commit b5a3a6b

Browse files
authored
Merge pull request #13 from lambda-feedback/workspace
Workspace: canvas and chat
2 parents 6fc7697 + 75a1d2d commit b5a3a6b

12 files changed

Lines changed: 183 additions & 3 deletions

docs/.DS_Store

2 KB
Binary file not shown.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Running and Testing Agents Locally
2+
3+
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`.
4+
5+
```bash
6+
python src/agents/utils/testbench_prompts.py
7+
```
8+
9+
You can also use the `test_prompts.py` script to test the agents with example inputs from Lambda Feedback questions and synthetic conversations.
10+
```bash
11+
python src/agents/utils/test_prompts.py
12+
```
13+
14+
## Testing using the Docker Image [:material-docker:](https://www.docker.com/)
15+
16+
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.
17+
18+
#### Build the Docker Image
19+
20+
To build the Docker image, run the following command in the root folder of the project (where the Dockerfile is located):
21+
22+
```bash
23+
docker build -t llm_chat .
24+
```
25+
26+
### Running the Docker Image
27+
28+
To run the Docker image, use the following command:
29+
30+
#### Without .env file:
31+
32+
```bash
33+
docker run -e OPENAI_API_KEY={your key} -e OPENAI_MODEL={your LLM chosen model name} -p 8080:8080 llm_chat
34+
```
35+
36+
#### With container name (for interaction, e.g. copying file from inside the docker container):
37+
38+
```bash
39+
docker run --env-file .env -it --name my-lambda-container -p 8080:8080 llm_chat
40+
```
41+
42+
This will start the evaluation function and expose it on port `8080` and it will be open to be curl:
43+
44+
```bash
45+
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"}]}}'
46+
```
47+
48+
### Call Docker Container From Postman
49+
50+
POST URL:
51+
52+
```bash
53+
http://localhost:8080/2015-03-31/functions/function/invocations
54+
```
55+
56+
Body:
57+
58+
```JSON
59+
{
60+
"message":"hi",
61+
"params":{
62+
"conversation_id":"12345Test",
63+
"conversation_history": [{"type":"user","content":"hi"}]
64+
}
65+
}
66+
```
67+
68+
Body with optional Params:
69+
```JSON
70+
{
71+
"message":"hi",
72+
"params":{
73+
"conversation_id":"12345Test",
74+
"conversation_history":[{"type":"user","content":"hi"}],
75+
"summary":" ",
76+
"conversational_style":" ",
77+
"question_response_details": "",
78+
"include_test_data": true,
79+
"agent_type": {agent_name}
80+
}
81+
}
82+
```
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Developing Chat Agents: Getting Started
2+
3+
## What is a Chat Agent?
4+
5+
It's a function which calls Large Language Models (LLMs) to respond to the student's messages given contxtual data:
6+
7+
- question data
8+
- user data such as past responses to the problem
9+
Chatbot Agents capture and automate the process of assisting students during their learning process when outside of classroom.
10+
11+
## Getting Setup for Development
12+
13+
1. Get the code on your local machine (Using github desktop or the `git` cli)
14+
15+
- 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.
16+
17+
- For existing functions: please make your changes on a new separate branch
18+
19+
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.
20+
3. You are now ready to start making changes and implementing features by editing each of the three main function-logic files:
21+
22+
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/).
23+
24+
- the agent expects the following inputs when it being called:
25+
26+
Body with necessary Params:
27+
28+
```JSON
29+
{
30+
"message":"hi",
31+
"params":{
32+
"conversation_id":"12345Test",
33+
"conversation_history": [{"type":"user","content":"hi"}]
34+
}
35+
}
36+
```
37+
38+
Body with optional Params:
39+
40+
```JSON
41+
{
42+
"message":"hi",
43+
"params":{
44+
"conversation_id":"12345Test",
45+
"conversation_history":[{"type":"user","content":"hi"}],
46+
"summary":" ",
47+
"conversational_style":" ",
48+
"question_response_details": "",
49+
"include_test_data": true,
50+
"agent_type": {agent_name}
51+
}
52+
}
53+
```
54+
55+
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.
56+
57+
3. Make sure to add your agent `invoke()` function to the `module.py` file.
58+
59+
4. Please add a `README.md` file to describe the use and behaviour of your agent.
60+
61+
4. Changes can be tested locally by running the pipeline tests using:
62+
```bash
63+
pytest src/module_test.py
64+
```
65+
[Running and Testing Agents Locally](local.md){ .md-button }
66+
67+
68+
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.
69+
70+
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.

docs/advanced/index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ Response areas are components in the frontend where student users can enter a re
1414

1515
[Response areas - overview](response_areas/overview.md){ .md-button .md-button--primary}
1616

17+
## AI Chatbot Agents
18+
19+
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.
20+
21+
[Chatbot Agents - Quickstart guide](chatbot_agents/quickstart.md){ .md-button .md-button--primary}
22+
1723
## System Architecture
1824

1925
- Technologies

docs/student/answering_questions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ If there is no response area (e.g. for a "show that..." question), you can manua
1212

1313
If you are stuck, you can view worked solutions using the "Worked Solutions" option on the bottom ribbon. The steps in the solution are
1414
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
15-
independantly.
15+
independently.
1616

1717
![The worked solutions area](images/worked_solutions.png)
1818

docs/student/getting_started_student.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,17 @@ See the [Answering Questions](answering_questions.md) page for more help with an
3333

3434
![The "Mark as done" box on the question page](images/mark_as_done.png)
3535

36+
### Using the Workspace
37+
38+
The Workspace provides you with various functionalities to assist you during your learning process:
39+
1. #### Canvas:
40+
A pane where you can write down your thought process and notes for the previewed question (handwriting, sticky notes & text).
41+
42+
![Canvas Interface](images/canvas_interface.png)
43+
44+
2. #### Chat:
45+
A chat interface connecting you with helpful AI Chatbots to discuss any questions you have on the current topic you are working on.
46+
47+
![Chat Interface](images/chat_interface.png)
48+
49+
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.

docs/student/image.png

-109 KB
Binary file not shown.
398 KB
Loading
481 KB
Loading
225 KB
Loading

0 commit comments

Comments
 (0)