Skip to content
Open

final #242

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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.venv
.env
.DS_Store
.DS_Store
.lab_cache/
.ipynb_checkpoints/
15 changes: 15 additions & 0 deletions SOLUTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Low-token lab solution

Open `solution.ipynb` and select the project's `.venv/bin/python` interpreter.
Dependencies are in `requirements-solution.txt`:

```sh
python3 -m venv .venv
.venv/bin/python -m pip install -r requirements-solution.txt
```

Set `OPENAI_API_KEY` in the ignored `.env` file. Run the notebook from top to bottom once. Saved outputs show the actual answers, tool choices and chat token counts. Embedding tokens are not included in the chat counter. Running the question cells again makes new paid chat calls.

The two small datasets are included. The Python Club handbook is original fictional data; the Ruff reference cites its official source. Document and query embeddings are cached in ignored `.lab_cache/`. The notebook uses the lab's LangChain 0.2 APIs and caps retrieval, response length and agent iterations. A multi-hop question uses both tools; a final single-source test demonstrates direct return.

Review the notebook outputs before submitting `solution.ipynb`, both new dataset files and `requirements-solution.txt`. Never commit `.env`, `.venv` or `.lab_cache`.
7 changes: 7 additions & 0 deletions datasets/python_club.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Python Club handbook — fictional teaching dataset created for this lab.

The Python Club meets on Wednesdays at 18:00 in Room 204. Members bring a laptop and a small Python project.

Before submitting a project, members must remove unused imports and sort imports. The club currently uses Flake8 for linting and isort for import sorting. The club wants fewer separate tools in its workflow.

Project submissions include a README, the Python source files, and a short explanation of one bug fixed during the session. The club mentor reviews submissions on Fridays.
7 changes: 7 additions & 0 deletions datasets/ruff_notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Ruff reference — a short paraphrase of official documentation.
Source: https://docs.astral.sh/ruff/
Retrieved: 2026-09-05. This is a small curated reference, not the full documentation.

Ruff is a Python linter and formatter implemented in Rust. It combines functionality from tools including Flake8 and isort. It supports pyproject.toml configuration and caches unchanged files.

Ruff can automatically fix some lint problems, including removing unused imports. It includes import-sorting functionality that can replace isort. Ruff emphasizes fast checks and an integrated interface.
9 changes: 9 additions & 0 deletions requirements-solution.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
langchain==0.2.17
langchain-community==0.2.19
langchain-openai==0.1.25
chromadb==0.5.23
numpy<2
python-dotenv>=1,<2
nbformat>=5,<6
nbclient>=0.10,<1
ipykernel>=6,<7
Loading