You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+22-16Lines changed: 22 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,13 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
4
4
5
5
## Project Overview
6
6
7
-
This is a chat function connecting students to an AI educational chatbot that is integrated with the **Lambda-Feedback** educational platform. It deploys as an AWS Lambda function (containerized via Docker) that receives student chat messages with educational context and returns LLM-powered chatbot responses. Incoming requests follow the [muEd API](https://mued.org/) schema (`context`, `user`, `messages`).
7
+
This is a chat function connecting students to an AI educational chatbot that is integrated with the **Lambda-Feedback** educational platform. It's containerized via Docker and deployed behind [shimmy](https://github.com/lambda-feedback/shimmy), a shim that spawns this function as a persistent JSON-RPC worker process and exposes it as the muEd `/chat` / `/chat/health` HTTP API (both locally and as an AWS Lambda container). Incoming requests follow the [muEd API](https://mued.org/) schema (`context`, `user`, `messages`).
8
8
9
9
## Commands
10
10
11
11
**Testing:**
12
12
```bash
13
-
pytest # Run all unit tests
13
+
PYTHONPATH=. pytest # Run all unit tests (CI sets PYTHONPATH=. too)
14
14
python tests/manual_agent_run.py # Test agent locally with example inputs
15
15
python tests/manual_agent_requests.py # Test running Docker container
Copy file name to clipboardExpand all lines: README.md
+20-13Lines changed: 20 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -119,7 +119,6 @@ The agent uses **two separate LLM instances** — `self.llm` for chat responses
119
119
├── manual_agent_run.py # allows testing of any LLM agent on a couple of example inputs
120
120
├── utils.py # shared test helpers
121
121
├── test_example_inputs.py # pytests for the example input files
122
-
├── test_index.py # pytests
123
122
└── test_module.py # pytests
124
123
```
125
124
@@ -130,18 +129,18 @@ To test your function, you can run the unit tests, call the code directly throug
130
129
131
130
### Run Unit Tests
132
131
133
-
You can run the unit tests using `pytest`.
132
+
You can run the unit tests using `pytest`. Run it from the repository root with `PYTHONPATH=.` set (as CI does) so the `tests` and `src` packages resolve correctly:
134
133
135
134
```bash
136
-
pytest
135
+
PYTHONPATH=. pytest
137
136
```
138
137
139
138
### Run the Chat Script
140
139
141
-
You can run the Python function itself. Make sure to have a main function in either `src/module.py`or `index.py`.
140
+
You can run the Python function itself directly — `index.py` wires `chat_module`/`chat_health_module` into `lf_toolkit`'s RPC server, the same way shimmy invokes it inside the container. This requires the `EVAL_IO`/`EVAL_RPC_TRANSPORT` environment variables shimmy would normally set (see `lf_toolkit`'s docs), so prefer the Docker or `manual_agent_run.py` routes below for everyday testing.
142
141
143
142
```bash
144
-
python src/module.py
143
+
python index.py
145
144
```
146
145
147
146
You can also use the `manual_agent_run.py` script to test the agents with example inputs from Lambda Feedback questions and synthetic conversations.
@@ -173,33 +172,41 @@ docker run -e OPENAI_API_KEY={your key} -e OPENAI_MODEL={your LLM model name} -p
173
172
docker run --env-file .env -it --name my-lambda-container -p 8080:8080 llm_chat
174
173
```
175
174
176
-
This will start the chat function and expose it on port `8080`and it will be open to be curl:
175
+
This starts shimmy (the [Lambda Feedback shim](https://github.com/lambda-feedback/shimmy)) as the container's entrypoint, which spawns this function as a worker subprocess and exposes it on port `8080`as the muEd chat API:
In the `tests/` folder you can find the `manual_agent_requests.py` script that calls the POST URL of the running docker container. It reads any kind of input files with the expected schema. You can use this to test your curl calls of the chatbot.
194
+
In the `tests/` folder you can find the `manual_agent_requests.py` script that calls the `/chat` and `/chat/health` routes of the running docker container. It reads any kind of input files with the expected schema. You can use this to test your curl calls of the chatbot.
188
195
189
196
##### B. Call Docker Container through API request
Per the [muEd `ChatRequest` schema](https://mued.org/), only `messages` is required; `conversationId`, `user`, `context`, and `configuration` are all optional.
204
+
Per the [muEd `ChatRequest` schema](https://mued.org/), only `messages` is required; `conversationId`, `user`, `context`, and `configuration` are all optional. Requests may include an `X-Api-Version: 0.1.0` header.
198
205
199
-
**Minimal request — only required components** (stringified within `body` for the AWS Lambda Runtime Interface Emulator):
Copy file name to clipboardExpand all lines: docs/dev.md
+17-9Lines changed: 17 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,10 +28,10 @@ To test your function, you can run the unit tests, call the code directly throug
28
28
29
29
### Run Unit Tests
30
30
31
-
You can run the unit tests using `pytest`.
31
+
You can run the unit tests using `pytest`. Run it from the repository root with `PYTHONPATH=.` set (as CI does) so the `tests` and `src` packages resolve correctly:
32
32
33
33
```bash
34
-
pytest
34
+
PYTHONPATH=. pytest
35
35
```
36
36
37
37
### Run the Chat Script
@@ -65,31 +65,39 @@ docker run -e OPENAI_API_KEY={your key} -e OPENAI_MODEL={your LLM chosen model n
65
65
docker run --env-file .env -it --name my-lambda-container -p 8080:8080 llm_chat
66
66
```
67
67
68
-
This will start the chat function and expose it on port `8080`and it will be open to be curl:
68
+
This starts shimmy (the [Lambda Feedback shim](https://github.com/lambda-feedback/shimmy)) as the container's entrypoint, which spawns this function as a worker subprocess and exposes it on port `8080`as the muEd chat API:
In the `tests/` folder you can find the `manual_agent_requests.py` script that calls the POST URL of the running docker container. It reads any kind of input files with the expected schema. You can use this to test your curl calls of the chatbot.
87
+
In the `tests/` folder you can find the `manual_agent_requests.py` script that calls the `/chat` and `/chat/health` routes of the running docker container. It reads any kind of input files with the expected schema. You can use this to test your curl calls of the chatbot.
80
88
81
89
##### B. Call Docker Container through API request
0 commit comments