Some checks failed
CI / backend-test (push) Successful in 4m9s
CI / frontend-test (push) Failing after 3m48s
CI / lint-python (push) Successful in 1m41s
CI / secret-scanning (push) Successful in 1m20s
CI / dependency-scan (push) Successful in 10m50s
CI / workflow-summary (push) Successful in 1m11s
## Features Added
### Document Reference System
- Implemented numbered document references (@1, @2, etc.) with autocomplete dropdown
- Added fuzzy filename matching for @filename references
- Document filtering now prioritizes numeric refs > filename refs > all documents
- Autocomplete dropdown appears when typing @ with keyboard navigation (Up/Down, Enter/Tab, Escape)
- Document numbers displayed in UI for easy reference
### Conversation Management
- Added conversation rename functionality with inline editing
- Implemented conversation search (by title and content)
- Search box always visible, even when no conversations exist
- Export reports now replace @N references with actual filenames
### UI/UX Improvements
- Removed debug toggle button
- Improved text contrast in dark mode (better visibility)
- Made input textarea expand to full available width
- Fixed file text color for better readability
- Enhanced document display with numbered badges
### Configuration & Timeouts
- Made HTTP client timeouts configurable (connect, write, pool)
- Added .env.example with all configuration options
- Updated timeout documentation
### Developer Experience
- Added `make test-setup` target for automated test conversation creation
- Test setup script supports TEST_MESSAGE and TEST_DOCS env vars
- Improved Makefile with dev and test-setup targets
### Documentation
- Updated ARCHITECTURE.md with all new features
- Created comprehensive deployment documentation
- Added GPU VM setup guides
- Removed unnecessary markdown files (CLAUDE.md, CONTRIBUTING.md, header.jpg)
- Organized documentation in docs/ directory
### GPU VM / Ollama (Stability + GPU Offload)
- Updated GPU VM docs to reflect the working systemd environment for remote Ollama
- Standardized remote Ollama port to 11434 (and added /v1/models verification)
- Documented required env for GPU offload on this VM:
- `OLLAMA_MODELS=/mnt/data/ollama`, `HOME=/mnt/data/ollama/home`
- `OLLAMA_LLM_LIBRARY=cuda_v12` (not `cuda`)
- `LD_LIBRARY_PATH=/usr/local/lib/ollama:/usr/local/lib/ollama/cuda_v12`
## Technical Changes
### Backend
- Enhanced `docs_context.py` with reference parsing (numeric and filename)
- Added `update_conversation_title` to storage.py
- New endpoints: PATCH /api/conversations/{id}/title, GET /api/conversations/search
- Improved report generation with filename substitution
### Frontend
- Removed debugMode state and related code
- Added autocomplete dropdown component
- Implemented search functionality in Sidebar
- Enhanced ChatInterface with autocomplete and improved textarea sizing
- Updated CSS for better contrast and responsive design
## Files Changed
- Backend: config.py, council.py, docs_context.py, main.py, storage.py
- Frontend: App.jsx, ChatInterface.jsx, Sidebar.jsx, and related CSS files
- Documentation: README.md, ARCHITECTURE.md, new docs/ directory
- Configuration: .env.example, Makefile
- Scripts: scripts/test_setup.py
## Breaking Changes
None - all changes are backward compatible
## Testing
- All existing tests pass
- New test-setup script validates conversation creation workflow
- Manual testing of autocomplete, search, and rename features
111 lines
3.7 KiB
Python
111 lines
3.7 KiB
Python
import os
|
|
import shutil
|
|
import tempfile
|
|
import unittest
|
|
import importlib
|
|
|
|
import httpx
|
|
|
|
|
|
class TestDocumentsApi(unittest.IsolatedAsyncioTestCase):
|
|
async def asyncSetUp(self):
|
|
self._old_env = dict(os.environ)
|
|
self.tmp = tempfile.mkdtemp(prefix="llm-council-docsapi-")
|
|
os.environ["DOCS_DIR"] = self.tmp
|
|
os.environ["MAX_DOC_BYTES"] = "1000000"
|
|
|
|
# Reload config/documents so they see DOCS_DIR override
|
|
import backend.config as config
|
|
import backend.documents as documents
|
|
import backend.main as main
|
|
|
|
importlib.reload(config)
|
|
importlib.reload(documents)
|
|
self.main = importlib.reload(main)
|
|
|
|
self.transport = httpx.ASGITransport(app=self.main.app)
|
|
self.client = httpx.AsyncClient(transport=self.transport, base_url="http://test")
|
|
|
|
# Create a conversation
|
|
resp = await self.client.post("/api/conversations", json={})
|
|
resp.raise_for_status()
|
|
self.conversation_id = resp.json()["id"]
|
|
|
|
async def asyncTearDown(self):
|
|
await self.client.aclose()
|
|
os.environ.clear()
|
|
os.environ.update(self._old_env)
|
|
shutil.rmtree(self.tmp, ignore_errors=True)
|
|
|
|
async def test_upload_and_list_documents(self):
|
|
# Upload
|
|
files = {"file": ("notes.md", b"# Hi\n", "text/markdown")}
|
|
resp = await self.client.post(
|
|
f"/api/conversations/{self.conversation_id}/documents",
|
|
files=files,
|
|
)
|
|
self.assertEqual(resp.status_code, 200, resp.text)
|
|
meta = resp.json()
|
|
self.assertIn("id", meta)
|
|
self.assertEqual(meta["filename"], "notes.md")
|
|
|
|
# List
|
|
resp2 = await self.client.get(
|
|
f"/api/conversations/{self.conversation_id}/documents"
|
|
)
|
|
self.assertEqual(resp2.status_code, 200, resp2.text)
|
|
items = resp2.json()
|
|
self.assertEqual(len(items), 1)
|
|
self.assertEqual(items[0]["id"], meta["id"])
|
|
|
|
async def test_upload_multiple_documents(self):
|
|
files = [
|
|
("files", ("a.md", b"one", "text/markdown")),
|
|
("files", ("b.md", b"two", "text/markdown")),
|
|
]
|
|
resp = await self.client.post(
|
|
f"/api/conversations/{self.conversation_id}/documents",
|
|
files=files,
|
|
)
|
|
self.assertEqual(resp.status_code, 200, resp.text)
|
|
payload = resp.json()
|
|
self.assertIn("uploaded", payload)
|
|
self.assertEqual(len(payload["uploaded"]), 2)
|
|
self.assertEqual({d["filename"] for d in payload["uploaded"]}, {"a.md", "b.md"})
|
|
|
|
async def test_rejects_non_md(self):
|
|
files = {"file": ("notes.txt", b"hello", "text/plain")}
|
|
resp = await self.client.post(
|
|
f"/api/conversations/{self.conversation_id}/documents",
|
|
files=files,
|
|
)
|
|
self.assertEqual(resp.status_code, 400)
|
|
|
|
async def test_get_and_delete_document(self):
|
|
files = {"file": ("a.md", b"hello", "text/markdown")}
|
|
up = await self.client.post(
|
|
f"/api/conversations/{self.conversation_id}/documents",
|
|
files=files,
|
|
)
|
|
self.assertEqual(up.status_code, 200)
|
|
doc_id = up.json()["id"]
|
|
|
|
get = await self.client.get(
|
|
f"/api/conversations/{self.conversation_id}/documents/{doc_id}"
|
|
)
|
|
self.assertEqual(get.status_code, 200)
|
|
self.assertEqual(get.json()["content"], "hello")
|
|
|
|
dele = await self.client.delete(
|
|
f"/api/conversations/{self.conversation_id}/documents/{doc_id}"
|
|
)
|
|
self.assertEqual(dele.status_code, 200)
|
|
self.assertTrue(dele.json()["ok"])
|
|
|
|
get2 = await self.client.get(
|
|
f"/api/conversations/{self.conversation_id}/documents/{doc_id}"
|
|
)
|
|
self.assertEqual(get2.status_code, 404)
|
|
|
|
|