Compare commits

...
23 Commits
Author SHA1 Message Date
Derek Bouius 06d11cf867 change the example openai model 2025-12-11 16:19:53 -05:00
Derek Bouius 7f5576cdee add best-match for the test-python-client too 2025-12-11 15:58:34 -05:00
Derek Bouius 3572387051 add best match strategy to uv 2025-12-11 15:51:16 -05:00
Derek Bouius 3a91c0b87f rework to use only CPU version of pytorch 2025-12-11 15:43:32 -05:00
Derek Bouius 706204bc4f force the CPU only version of Pytorch for tests 2025-12-11 14:58:43 -05:00
Derek Bouius 147d46fc91 Revert "use the CPU only version of pytorch to avoid pulling cuda libraries"
This reverts commit 583683b0a2.
2025-12-11 14:44:59 -05:00
Derek Bouius 285bed65f9 Revert "just use uv sync, not pip"
This reverts commit c85a1ca58b.
2025-12-11 14:44:51 -05:00
Derek Bouius c85a1ca58b just use uv sync, not pip 2025-12-11 14:21:45 -05:00
Derek Bouius 583683b0a2 use the CPU only version of pytorch to avoid pulling cuda libraries 2025-12-11 14:12:43 -05:00
Derek Bouius 0d5503c892 add debug to figure out why docker build fails sometimes 2025-12-11 13:51:06 -05:00
Derek Bouius af2756f2da remove assert that is a race condition
The test was checking that the bank count increased, but with parallel tests (-n 8), other tests can delete their banks while this test is running, causing a race condition. The important assertion is assert test_bank_id in final_banks - which verifies the bank was actually created.
2025-12-11 13:19:09 -05:00
Derek Bouius b1e380bdae Merge branch 'update-example-env' of https://github.com/vectorize-io/hindsight into update-example-env 2025-12-11 13:08:42 -05:00
Derek Bouius b8ec743962 pre-cache the model so CI doesn't need workarounds 2025-12-11 13:08:39 -05:00
Derek Bouius d891124835 Revert "trial to fix failing client tests"
This reverts commit c0093f1a97.
2025-12-11 16:08:22 +01:00
Derek Bouius 04ff24be8d trial to fix failing client tests
NotImplementedError: Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty() instead of torch.nn.Module.to() when moving module from meta to a different device.

Added backend_kwargs={"low_cpu_mem_usage": False} to the SentenceTransformer initialization in embeddings.py
This should ensure the low_cpu_mem_usage=False setting is passed through both model_kwargs and backend_kwargs, which are different code paths in sentence-transformers 3.x.
2025-12-11 16:08:22 +01:00
Derek Bouius 076c33e854 fix the assert in testing recall 2025-12-11 16:08:22 +01:00
Derek Bouius a03c942296 Add the LLM_PROVIDER in example 2025-12-11 16:08:22 +01:00
Derek Bouius b4e42bd0c6 lock the sentence transformer packages to align with the breaking changes around lazy tensor loading 2025-12-11 09:46:28 -05:00
Derek Bouius 95b2b7e78f Merge branch 'main' into update-example-env 2025-12-11 09:22:35 -05:00
Derek Bouius 2aa8700db8 Revert "trial to fix failing client tests"
This reverts commit c0093f1a97.
2025-12-10 23:11:04 -05:00
Derek Bouius c0093f1a97 trial to fix failing client tests
NotImplementedError: Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty() instead of torch.nn.Module.to() when moving module from meta to a different device.

Added backend_kwargs={"low_cpu_mem_usage": False} to the SentenceTransformer initialization in embeddings.py
This should ensure the low_cpu_mem_usage=False setting is passed through both model_kwargs and backend_kwargs, which are different code paths in sentence-transformers 3.x.
2025-12-10 23:04:42 -05:00
Derek Bouius 460f045f16 fix the assert in testing recall 2025-12-10 22:36:40 -05:00
Derek Bouius 0673d4813d Add the LLM_PROVIDER in example 2025-12-10 22:22:26 -05:00
7 changed files with 52 additions and 19 deletions
+2 -1
View File
@@ -2,8 +2,9 @@
# Copy this file to .env and fill in your values
# LLM Configuration (Required)
HINDSIGHT_API_LLM_PROVIDER=openai
HINDSIGHT_API_LLM_API_KEY=your-api-key-here
HINDSIGHT_API_LLM_MODEL=gpt-4o-mini
HINDSIGHT_API_LLM_MODEL=o3-mini
HINDSIGHT_API_LLM_BASE_URL=https://api.openai.com/v1
# API Configuration (Optional)
+33 -5
View File
@@ -108,6 +108,8 @@ jobs:
HINDSIGHT_API_LLM_API_KEY: ${{ secrets.GROQ_API_KEY }}
HINDSIGHT_API_LLM_MODEL: openai/gpt-oss-20b
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Prefer CPU-only PyTorch in CI (but keep PyPI for everything else)
UV_INDEX: pytorch=https://download.pytorch.org/whl/cpu
steps:
- uses: actions/checkout@v4
@@ -132,7 +134,27 @@ jobs:
- name: Install dependencies
working-directory: ./hindsight-api
run: uv sync --extra test
run: uv sync --extra test --no-install-project --index-strategy unsafe-best-match
- name: Cache HuggingFace models
uses: actions/cache@v4
with:
path: ~/.cache/huggingface
key: ${{ runner.os }}-huggingface-${{ hashFiles('hindsight-api/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-huggingface-
- name: Pre-download models
working-directory: ./hindsight-api
run: |
uv run python -c "
from sentence_transformers import SentenceTransformer, CrossEncoder
print('Downloading embedding model...')
SentenceTransformer('BAAI/bge-small-en-v1.5')
print('Downloading cross-encoder model...')
CrossEncoder('cross-encoder/ms-marco-MiniLM-L-6-v2')
print('Models downloaded successfully')
"
- name: Run tests
working-directory: ./hindsight-api
@@ -146,6 +168,8 @@ jobs:
HINDSIGHT_API_LLM_MODEL: openai/gpt-oss-20b
HINDSIGHT_API_URL: http://localhost:8888
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Prefer CPU-only PyTorch in CI (but keep PyPI for everything else)
UV_INDEX: pytorch=https://download.pytorch.org/whl/cpu
steps:
- uses: actions/checkout@v4
@@ -174,11 +198,11 @@ jobs:
- name: Install client test dependencies
working-directory: ./hindsight-clients/python
run: uv sync --extra test
run: uv sync --extra test --index-strategy unsafe-best-match
- name: Install API dependencies
working-directory: ./hindsight-api
run: uv sync
run: uv sync --no-install-project --index-strategy unsafe-best-match
- name: Create .env file
run: |
@@ -223,6 +247,8 @@ jobs:
HINDSIGHT_API_LLM_MODEL: openai/gpt-oss-20b
HINDSIGHT_API_URL: http://localhost:8888
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Prefer CPU-only PyTorch in CI (but keep PyPI for everything else)
UV_INDEX: pytorch=https://download.pytorch.org/whl/cpu
steps:
- uses: actions/checkout@v4
@@ -252,7 +278,7 @@ jobs:
- name: Install API dependencies
working-directory: ./hindsight-api
run: uv sync
run: uv sync --no-install-project --index-strategy unsafe-best-match
- name: Install TypeScript client dependencies
working-directory: ./hindsight-clients/typescript
@@ -305,6 +331,8 @@ jobs:
HINDSIGHT_API_LLM_MODEL: openai/gpt-oss-20b
HINDSIGHT_API_URL: http://localhost:8888
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Prefer CPU-only PyTorch in CI (but keep PyPI for everything else)
UV_INDEX: pytorch=https://download.pytorch.org/whl/cpu
steps:
- uses: actions/checkout@v4
@@ -341,7 +369,7 @@ jobs:
- name: Install API dependencies
working-directory: ./hindsight-api
run: uv sync
run: uv sync --no-install-project --index-strategy unsafe-best-match
- name: Create .env file
run: |
+10 -2
View File
@@ -147,9 +147,13 @@ RUN mkdir -p /home/hindsight/.hindsight/bin && \
curl -fsSL -o /home/hindsight/.hindsight/bin/pg0 \
"https://github.com/vectorize-io/pg0/releases/latest/download/$PG0_BINARY" && \
chmod +x /home/hindsight/.hindsight/bin/pg0 && \
ls -lh /home/hindsight/.hindsight/bin/pg0 && \
file /home/hindsight/.hindsight/bin/pg0 && \
ldd /home/hindsight/.hindsight/bin/pg0 2>&1 || true && \
break || (echo "Retry $i failed, waiting..." && sleep 10); \
done && \
/home/hindsight/.hindsight/bin/pg0 --version
echo "Testing pg0 binary..." && \
/home/hindsight/.hindsight/bin/pg0 --version || (echo "pg0 --version failed with exit code $?"; ldd /home/hindsight/.hindsight/bin/pg0; exit 1)
# Pre-download PostgreSQL binaries
ENV PG0_HOME=/home/hindsight/.pg0-cache
@@ -280,9 +284,13 @@ RUN mkdir -p /home/hindsight/.hindsight/bin && \
curl -fsSL -o /home/hindsight/.hindsight/bin/pg0 \
"https://github.com/vectorize-io/pg0/releases/latest/download/$PG0_BINARY" && \
chmod +x /home/hindsight/.hindsight/bin/pg0 && \
ls -lh /home/hindsight/.hindsight/bin/pg0 && \
file /home/hindsight/.hindsight/bin/pg0 && \
ldd /home/hindsight/.hindsight/bin/pg0 2>&1 || true && \
break || (echo "Retry $i failed, waiting..." && sleep 10); \
done && \
/home/hindsight/.hindsight/bin/pg0 --version
echo "Testing pg0 binary..." && \
/home/hindsight/.hindsight/bin/pg0 --version || (echo "pg0 --version failed with exit code $?"; ldd /home/hindsight/.hindsight/bin/pg0; exit 1)
# Pre-download PostgreSQL binaries
ENV PG0_HOME=/home/hindsight/.pg0-cache
@@ -101,12 +101,7 @@ class LocalSTCrossEncoder(CrossEncoderModel):
)
logger.info(f"Reranker: initializing local provider with model {self.model_name}")
# Disable lazy loading (meta tensors) which causes issues with newer transformers/accelerate
# Setting low_cpu_mem_usage=False and device_map=None ensures tensors are fully materialized
self._model = CrossEncoder(
self.model_name,
model_kwargs={"low_cpu_mem_usage": False, "device_map": None},
)
self._model = CrossEncoder(self.model_name)
logger.info("Reranker: local provider initialized")
def predict(self, pairs: List[Tuple[str, str]]) -> List[float]:
+3 -3
View File
@@ -14,7 +14,7 @@ dependencies = [
"openai>=1.0.0",
"pydantic>=2.0.0",
"rich>=13.0.0",
"sentence-transformers>=3.0.0",
"sentence-transformers>=3.0.0,<3.3.0",
"langchain-text-splitters>=0.3.0",
"fastapi[standard]>=0.120.3",
"uvicorn>=0.38.0",
@@ -24,8 +24,8 @@ dependencies = [
"pgvector>=0.4.1",
"greenlet>=3.2.4",
"psycopg2-binary>=2.9.11",
"transformers>=4.30.0",
"torch>=2.0.0",
"transformers>=4.30.0,<4.46.0",
"torch>=2.0.0,<2.6.0",
"tiktoken>=0.12.0",
"httpx>=0.27.0",
"fastmcp>=2.0.0",
@@ -281,7 +281,8 @@ async def test_full_api_workflow(api_client, test_bank_id):
final_banks_data = response.json()["banks"]
final_banks = [a["bank_id"] for a in final_banks_data]
assert test_bank_id in final_banks
assert len(final_banks) >= len(initial_banks) + 1
# Don't assert count increases due to parallel test cleanup races
# Just verify our bank exists in the list
# ================================================================
# 10. Clean Up
@@ -239,7 +239,7 @@ class TestEndToEndWorkflow:
bank_id=workflow_bank_id,
query="What programming technologies do I use?",
)
assert len(search_results) > 0
assert len(search_results.results) > 0
# 4. Generate contextual answer
reflect_response = client.reflect(