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
50 changes: 24 additions & 26 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
{
"name": "Python 3.10",
"image": "mcr.microsoft.com/devcontainers/python:3.10-bookworm",
"customizations": {
"vscode": {
"settings": {
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"files.exclude": {
".coverage": true,
".pytest_cache": true,
"__pycache__": true
}
},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"charliermarsh.ruff",
"ms-python.black-formatter"
]
"name": "Python 3.10",
"image": "mcr.microsoft.com/devcontainers/python:3.10-bookworm",
"customizations": {
"vscode": {
"settings": {
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"files.exclude": {
".coverage": true,
".pytest_cache": true,
"__pycache__": true
}
},
"forwardPorts": [
8501
],
"postCreateCommand": "pipx install poetry && make install-deps-dev",
"remoteUser": "vscode"
},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"charliermarsh.ruff",
"ms-python.black-formatter"
]
}
},
"forwardPorts": [8501],
"postCreateCommand": "pipx install uv && make install-deps-dev",
"remoteUser": "vscode"
}
5 changes: 2 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ jobs:
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Set up Poetry
- name: Set up uv
shell: bash
run: pipx install poetry
run: pipx install uv
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
- name: Run CI tests
shell: bash
run: |
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ FROM python:3.11.8-slim-bookworm AS requirements-stage

WORKDIR /tmp

RUN pip install --no-cache-dir poetry==1.8.2
RUN pip install --no-cache-dir uv==0.5.12

COPY ./pyproject.toml ./poetry.lock* /tmp/
COPY ./pyproject.toml ./uv.lock /tmp/

RUN poetry export --without=dev -f requirements.txt --output requirements.txt --without-hashes
RUN uv export --format requirements-txt --no-dev --no-hashes --output-file requirements.txt

FROM python:3.11.8-slim-bookworm

Expand Down
25 changes: 14 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,32 @@ info: ## show information

.PHONY: install-deps-dev
install-deps-dev: ## install dependencies for development
poetry install
poetry run pre-commit install
uv sync --all-extras
uv run pre-commit install

.PHONY: install-deps
install-deps: ## install dependencies for production
poetry install --without dev
uv sync --no-dev

.PHONY: format-check
format-check: ## format check
poetry run black . --check --verbose
uv run ruff format --check --verbose

.PHONY: format
format: ## format code
poetry run isort .
poetry run black . --verbose
uv run ruff format --verbose

.PHONY: fix
fix: format ## apply auto-fixes
poetry run ruff check --fix
uv run ruff check --fix

.PHONY: lint
lint: ## lint
poetry run ruff check .
uv run ruff check .

.PHONY: test
test: ## run tests
poetry run pytest --capture=no
uv run pytest --capture=no -vv

.PHONY: ci-test
ci-test: install-deps-dev format-check lint test ## run CI tests
Expand Down Expand Up @@ -81,17 +80,21 @@ docker-scan: ## scan Docker image
.PHONY: ci-test-docker
ci-test-docker: docker-lint docker-build docker-run ## run CI test for Docker

.PHONY: update
update: ## update packages
uv lock --upgrade

# ---
# Docs
# ---

.PHONY: docs
docs: ## build documentation
poetry run mkdocs build
uv run mkdocs build

.PHONY: docs-serve
docs-serve: ## serve documentation
poetry run mkdocs serve
uv run mkdocs serve

.PHONY: ci-test-docs
ci-test-docs: docs ## run CI test for documentation
1 change: 0 additions & 1 deletion apps/11_promptflow/eval-chat-math/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

@tool
def accuracy_aggregate(processed_results: list[int]):

num_exception = 0
num_correct = 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class GradeAnswer(BaseModel):

binary_score: bool = Field(description="Answer addresses the question, 'yes' or 'no'")


Expand Down
2 changes: 1 addition & 1 deletion apps/13_langchain_toolkits/playwright_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def get_yahoo_realtime_trends(
page.goto(url="https://search.yahoo.co.jp/realtime")
trends = []
for i in range(20):
keyword = page.get_by_role("link", name=f"{i+1}", exact=True).text_content()
keyword = page.get_by_role("link", name=f"{i + 1}", exact=True).text_content()
trends.append(
{
"rank": i + 1,
Expand Down
4 changes: 2 additions & 2 deletions docs/apps/13_langchain_toolkits.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ $ npx playwright codegen --target=python
##### [PlayWright Browser Toolkit](https://python.langchain.com/docs/integrations/tools/playwright/)

```shell
$ poetry run playwright install
$ uv run playwright install

$ poetry run python apps/13_langchain_toolkits/playwright_tool.py
$ uv run python apps/13_langchain_toolkits/playwright_tool.py
```

Sample output:
Expand Down
4 changes: 2 additions & 2 deletions docs/apps/14_streamlit_azure_ai_speech.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ This app demonstrates how to use Azure AI Speech Service for realtime transcript

```shell
# Speech to Text script
poetry run python apps/14_streamlit_azure_ai_speech/speech_to_text.py --help
uv run python apps/14_streamlit_azure_ai_speech/speech_to_text.py --help

# WIP: Streamlit app
poetry run python -m streamlit run apps/14_streamlit_azure_ai_speech/main.py
uv run python -m streamlit run apps/14_streamlit_azure_ai_speech/main.py
```

# References
Expand Down
14 changes: 7 additions & 7 deletions docs/apps/15_streamlit_chat_slm.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ $ ollama serve
$ ollama pull phi3

# Run a simple chat with Ollama
$ poetry run python apps/15_streamlit_chat_slm/chat.py
$ uv run python apps/15_streamlit_chat_slm/chat.py

# Run summarization with SLM
$ poetry run python apps/15_streamlit_chat_slm/summarize.py
$ uv run python apps/15_streamlit_chat_slm/summarize.py

# Run streamlit app
$ poetry run python -m streamlit run apps/15_streamlit_chat_slm/main.py
$ uv run python -m streamlit run apps/15_streamlit_chat_slm/main.py

# List models
$ ollama list
Expand All @@ -34,7 +34,7 @@ phi4:latest ac896e5b8b34 9.1 GB 55 minutes ago
$ ollama pull phi3

# Measure time to run the chat
$ time poetry run python apps/15_streamlit_chat_slm/chat.py \
$ time uv run python apps/15_streamlit_chat_slm/chat.py \
--model phi3 \
--prompt "hello"
{
Expand Down Expand Up @@ -68,7 +68,7 @@ $ time poetry run python apps/15_streamlit_chat_slm/chat.py \
"total_tokens": 32
}
}
poetry run python apps/15_streamlit_chat_slm/chat.py --model phi3 --prompt 1.57s user 0.16s system 68% cpu 2.515 total
uv run python apps/15_streamlit_chat_slm/chat.py --model phi3 --prompt 1.57s user 0.16s system 68% cpu 2.515 total
```

### Use Phi4 model
Expand All @@ -78,7 +78,7 @@ poetry run python apps/15_streamlit_chat_slm/chat.py --model phi3 --prompt 1.5
$ ollama pull phi4

# Measure time to run the chat
$ time poetry run python apps/15_streamlit_chat_slm/chat.py \
$ time uv run python apps/15_streamlit_chat_slm/chat.py \
--model phi4 \
--prompt "hello"
{
Expand Down Expand Up @@ -112,7 +112,7 @@ $ time poetry run python apps/15_streamlit_chat_slm/chat.py \
"total_tokens": 51
}
}
poetry run python apps/15_streamlit_chat_slm/chat.py --model phi4 --prompt 1.48s user 0.12s system 12% cpu 12.455 total
uv run python apps/15_streamlit_chat_slm/chat.py --model phi4 --prompt 1.48s user 0.12s system 12% cpu 12.455 total
```

Note:
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ To run all the projects in this repository, you need the followings.

Here are the preferred tools for development.

- [Poetry](https://python-poetry.org/docs/#installation)
- [uv](https://docs.astral.sh/uv/getting-started/installation/)
Copy link
Preview

Copilot AI May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] For consistency and clarity across the docs, consider capitalizing the tool name in the link label (e.g., UV instead of uv).

Suggested change
- [uv](https://docs.astral.sh/uv/getting-started/installation/)
- [UV](https://docs.astral.sh/uv/getting-started/installation/)

Copilot uses AI. Check for mistakes.

- [GNU Make](https://www.gnu.org/software/make/)

## Setup
Expand Down
Loading