Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
90 changes: 79 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ['3.12', '3.13', '3.14', '3.15.0rc1']
python-version: ['3.12', '3.13', '3.14', '3.15']
exclude:
- os: windows-latest
python-version: '3.13'
- os: windows-latest
python-version: '3.15.0rc1'
python-version: '3.15'
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} check (py ${{ matrix.python-version }})

Expand All @@ -66,14 +66,24 @@ jobs:
persist-credentials: false

- name: Set up Python
id: setup-python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
version: "0.12.1"
version: "0.12.2"

# Without this, 'uv sync' downloads a managed Python of its own choosing
# and the python-version matrix has no effect at all.
- name: Point uv at the matrix interpreter
shell: bash
env:
PYTHON_PATH: ${{ steps.setup-python.outputs.python-path }}
run: echo "UV_PYTHON=$PYTHON_PATH" >> "$GITHUB_ENV"
Comment on lines +82 to +86

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ignore for now

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

But what to do about it? It does look like this will just fail on Windows, doesn't it? And there's no bash shell on Windows.


- name: Run Check (Linux)
if: runner.os == 'Linux'
Expand All @@ -91,14 +101,14 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ['3.12', '3.13', '3.14', '3.15.0rc1']
python-version: ['3.12', '3.13', '3.14', '3.15']
exclude:
- os: windows-latest
python-version: '3.13'
- os: windows-latest
python-version: '3.14'
- os: windows-latest
python-version: '3.15.0rc1'
python-version: '3.15'
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} format (py ${{ matrix.python-version }})

Expand All @@ -109,37 +119,51 @@ jobs:
persist-credentials: false

- name: Set up Python
id: setup-python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
version: "0.12.1"
version: "0.12.2"

# Without this, 'uv sync' downloads a managed Python of its own choosing
# and the python-version matrix has no effect at all.
- name: Point uv at the matrix interpreter
shell: bash
env:
PYTHON_PATH: ${{ steps.setup-python.outputs.python-path }}
run: echo "UV_PYTHON=$PYTHON_PATH" >> "$GITHUB_ENV"

# --check makes this fail on unformatted code instead of silently
# reformatting the checkout and passing.
- name: Run Format (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
make format
make format FLAGS=--check

- name: Run Format (Windows)
if: runner.os == 'Windows'
run: |
./make.bat format
./make.bat format --check

offline-test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ['3.12', '3.13', '3.14', '3.15.0rc1']
python-version: ['3.12', '3.13', '3.14', '3.15']
# Same reduced Windows coverage as the 'check' job: oldest and newest
# stable, no 3.13 and no pre-release.
exclude:
- os: windows-latest
python-version: '3.13'
- os: windows-latest
python-version: '3.14'
python-version: '3.15'
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} (py ${{ matrix.python-version }})

Expand All @@ -150,14 +174,24 @@ jobs:
persist-credentials: false

- name: Set up Python
id: setup-python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
version: "0.12.1"
version: "0.12.2"

# Without this, 'uv sync' downloads a managed Python of its own choosing
# and the python-version matrix has no effect at all.
- name: Point uv at the matrix interpreter
shell: bash
env:
PYTHON_PATH: ${{ steps.setup-python.outputs.python-path }}
run: echo "UV_PYTHON=$PYTHON_PATH" >> "$GITHUB_ENV"

- name: Run Test (Linux)
if: runner.os == 'Linux'
Expand All @@ -170,6 +204,40 @@ jobs:
run: |
./make.bat test

# 'make all' ends in 'make build'; without this the packaging step is
# never exercised in CI.
build:
runs-on: ubuntu-latest
name: build (py 3.14)

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
persist-credentials: false

- name: Set up Python
id: setup-python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.14'

- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
version: "0.12.2"

- name: Point uv at the matrix interpreter
shell: bash
env:
PYTHON_PATH: ${{ steps.setup-python.outputs.python-path }}
run: echo "UV_PYTHON=$PYTHON_PATH" >> "$GITHUB_ENV"

- name: Run Build
shell: bash
run: |
make build

# online-test:
# needs: permissions-check
# environment:
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ format: venv
.PHONY: check
check: venv
uv run pyright --pythonversion 3.12 src tests tools examples
uv run pyright --pythonversion 3.13 src tests tools examples
uv run pyright --pythonversion 3.14 src tests tools examples
uv run pyright --pythonversion 3.15 src tests tools examples
Comment thread
bmerkle marked this conversation as resolved.

.PHONY: test
test: venv
Expand Down Expand Up @@ -64,13 +66,17 @@ release: venv
.PHONY: venv
venv: .venv

.venv:
# Re-sync when the dependencies change, not just when .venv/ is missing.
# The final 'touch' is needed because 'uv sync' leaves .venv/'s own timestamp
# alone, which would make this target look perpetually out of date.
.venv: pyproject.toml uv.lock
@echo "(If 'uv' fails with 'No such file or directory', try 'make install-uv')"
uv sync -q $(FLAGS)
Comment thread
bmerkle marked this conversation as resolved.
Outdated
uv run black --version
@echo "(If 'pyright' fails with 'error while loading shared libraries: libatomic.so.1:', try 'make install-libatomic')"
uv run pyright --version
uv run pytest --version
@touch .venv

.PHONY: sync
sync:
Expand Down
11 changes: 8 additions & 3 deletions make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,22 @@ if /I "%~1"=="help" goto help
echo Unknown command: %~1
goto help

:: Extra arguments are passed on to the tools, e.g. '.\make format --check'.
Comment thread
bmerkle marked this conversation as resolved.
Outdated
:format
if not exist ".venv\" call make.bat venv
echo Formatting code...
uv run isort src tests tools examples
uv run black -tpy312 src tests tools examples
uv run isort src tests tools examples %2 %3 || exit /b 1
uv run black -tpy312 src tests tools examples %2 %3 || exit /b 1
Comment thread
bmerkle marked this conversation as resolved.
Outdated
goto end

:: Keep the checked versions in sync with the 'check' target in the Makefile.
:check
if not exist ".venv\" call make.bat venv
echo Running type checks...
uv run pyright src tests tools examples
uv run pyright --pythonversion 3.12 src tests tools examples || exit /b 1
uv run pyright --pythonversion 3.13 src tests tools examples || exit /b 1
uv run pyright --pythonversion 3.14 src tests tools examples || exit /b 1
uv run pyright --pythonversion 3.15 src tests tools examples || exit /b 1
goto end

:test
Expand Down
53 changes: 28 additions & 25 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,35 @@ classifiers = [
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15.0rc1",
"Programming Language :: Python :: 3.15",
"Programming Language :: Python :: Implementation :: CPython",
"Typing :: Typed",
]
dependencies = [
Comment thread
bmerkle marked this conversation as resolved.
"azure-identity>=1.22.0",
"azure-identity>=1.25.3",
"colorama>=0.4.6",
"mcp[cli]>=1.12.1",
"numpy>=2.2.6",
"openai>=1.81.0",
"pydantic>=2.13.4; python_version >= '3.15'",
"pydantic>=2.10.0; python_version < '3.15'",
# mcp 2.0 dropped mcp.server.fastmcp; src/typeagent/mcp/server.py needs
# porting to the new MCPServer API before the cap can be lifted.
"mcp[cli]>=1.29.0,<2",
"numpy>=2.5.1",
"openai>=2.53.0",
# Only pydantic-core 2.48+ (pydantic 2.14) ships cp315 wheels.
Comment thread
bmerkle marked this conversation as resolved.
Outdated
"pydantic>=2.14.0b1; python_version >= '3.15'",
"pydantic>=2.13.4; python_version < '3.15'",
"pydantic-ai-slim[openai]>=2.25.0",
"pyreadline3>=3.5.4 ; sys_platform == 'win32'",
"python-dotenv>=1.1.0",
"pyreadline3>=3.5.6 ; sys_platform == 'win32'",
"python-dotenv>=1.2.2",
"stamina>=26.1.0",
"tiktoken>=0.13.0",
"typechat>=0.0.4",
"typechat>=0.0.5",
"webvtt-py>=0.5.1",
]

[project.optional-dependencies]
# Needed to enable --logfire flag to tools/query.py
logfire = [
"logfire>=4.1.0",
"opentelemetry-instrumentation-httpx>=0.57b0",
"logfire>=4.40.0",
"opentelemetry-instrumentation-httpx>=0.65b0",
]

[project.urls]
Expand All @@ -58,7 +61,7 @@ Documentation = "https://github.com/microsoft/typeagent-py/tree/main/docs/README

[tool.uv]
constraint-dependencies = [
"python-multipart>=0.0.27",
"python-multipart>=0.0.32",
]

[tool.uv.build-backend]
Expand Down Expand Up @@ -88,17 +91,17 @@ known_local_folder = ["conftest"]
dev = [
Comment thread
bmerkle marked this conversation as resolved.
"azure-mgmt-authorization>=4.0.0",
"azure-mgmt-keyvault>=14.0.1",
"black>=24.4.2",
"coverage[toml]>=7.6.0",
"google-api-python-client>=2.140.0",
"google-auth-httplib2>=0.2.0",
"google-auth-oauthlib>=1.2.1",
"isort>=5.13.2",
"logfire>=4.32.1", # So 'make check' passes
"msgraph-sdk>=1.56.0",
"opentelemetry-instrumentation-httpx>=0.61b0",
"pyright>=1.1.390",
"pytest>=8.3.3",
"pytest-asyncio>=0.24.0",
"black>=26.5.1",
"coverage[toml]>=7.15.4",
"google-api-python-client>=2.198.0",
"google-auth-httplib2>=0.4.1",
"google-auth-oauthlib>=1.4.0",
"isort>=8.0.1",
"logfire>=4.40.0", # So 'make check' passes
"msgraph-sdk>=1.61.0",
"opentelemetry-instrumentation-httpx>=0.65b0",
"pyright>=1.1.411",
"pytest>=9.1.1",
"pytest-asyncio>=1.4.0",
"pytest-mock>=3.15.1",
]
6 changes: 3 additions & 3 deletions src/typeagent/aitools/vectorbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def add_embedding(
embedding_array = np.asarray(embedding, dtype=np.float32)
if self._embedding_size == 0:
self._set_embedding_size(len(embedding_array))
self._vectors.shape = (0, self._embedding_size)
self._vectors = self._vectors.reshape(0, self._embedding_size)
Comment thread
bmerkle marked this conversation as resolved.
if len(embedding_array) != self._embedding_size:
raise ValueError(
f"Embedding size mismatch: expected {self._embedding_size}, "
Expand All @@ -136,7 +136,7 @@ def add_embeddings(
raise ValueError(f"Expected 2D embeddings array, got {embeddings.ndim}D")
if self._embedding_size == 0:
self._set_embedding_size(embeddings.shape[1])
self._vectors.shape = (0, self._embedding_size)
self._vectors = self._vectors.reshape(0, self._embedding_size)
if embeddings.shape[1] != self._embedding_size:
raise ValueError(
f"Embedding size mismatch: expected {self._embedding_size}, "
Expand Down Expand Up @@ -253,7 +253,7 @@ def _set_embedding_size(self, size: int) -> None:
def clear(self) -> None:
self._vectors = np.array([], dtype=np.float32)
if self._embedding_size > 0:
self._vectors.shape = (0, self._embedding_size)
self._vectors = self._vectors.reshape(0, self._embedding_size)

def get_embedding_at(self, pos: int) -> NormalizedEmbedding:
if 0 <= pos < len(self._vectors):
Expand Down
Loading
Loading