-
Notifications
You must be signed in to change notification settings - Fork 4
feat: migrate website search and embeddings to crawler service #595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0c7ec74
feat: migrate website search and embeddings from Convex to crawler se…
larryro d67b7e6
feat: add search UI, chunk inspection, and async website registration
larryro 68b7e59
feat(crawler): replace custom chunker with semantic-text-splitter Mar…
larryro 53abe48
refactor(db): rename search database from tale_crawler_search to tale…
larryro ebe30b2
fix(crawler): harden embedding config, error handling, and website sync
larryro 2143645
fix(crawler): pin embedding column dimensions at startup for HNSW ind…
larryro 58b79f1
fix: resolve CI lint, typecheck, and knip failures
larryro b628a56
fix: format services/platform/package.json
larryro b082703
fix(crawler): use paradedb.match() for FTS to handle special characte…
larryro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,13 @@ class Settings(BaseSettings): | |
| # Concurrency for Vision processing | ||
| vision_max_concurrent_pages: int = 3 | ||
|
|
||
| # Database configuration | ||
| database_url: str | None = None | ||
|
|
||
| # Embedding model configuration | ||
| openai_embedding_model: str | None = None | ||
| embedding_dimensions: int | None = None | ||
|
|
||
| model_config = SettingsConfigDict( | ||
| env_prefix="CRAWLER_", | ||
| env_file=".env", | ||
|
|
@@ -76,6 +83,26 @@ def get_fast_model(self) -> str: | |
| raise ValueError("OPENAI_FAST_MODEL must be set in environment.") | ||
| return model | ||
|
|
||
| def get_embedding_model(self) -> str: | ||
| """Get embedding model from CRAWLER_OPENAI_EMBEDDING_MODEL or OPENAI_EMBEDDING_MODEL.""" | ||
| model = get_first_model(self.openai_embedding_model) or get_first_model( | ||
| os.environ.get("OPENAI_EMBEDDING_MODEL") | ||
| ) | ||
| if not model: | ||
| raise ValueError("OPENAI_EMBEDDING_MODEL must be set in environment.") | ||
| return model | ||
|
|
||
| def get_embedding_dimensions(self) -> int: | ||
| """Get embedding dimensions from CRAWLER_EMBEDDING_DIMENSIONS or EMBEDDING_DIMENSIONS.""" | ||
| dims = self.embedding_dimensions | ||
| if dims is None: | ||
| raw = os.environ.get("EMBEDDING_DIMENSIONS") | ||
| if raw is not None: | ||
| dims = int(raw) | ||
| if dims is None: | ||
| raise ValueError("EMBEDDING_DIMENSIONS must be set in environment.") | ||
| return dims | ||
|
Comment on lines
+95
to
+104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validate embedding dimensions as a positive integer at config boundary. Line 101 currently accepts non-positive values (e.g., Suggested hardening patch def get_embedding_dimensions(self) -> int:
"""Get embedding dimensions from CRAWLER_EMBEDDING_DIMENSIONS or EMBEDDING_DIMENSIONS."""
dims = self.embedding_dimensions
if dims is None:
raw = os.environ.get("EMBEDDING_DIMENSIONS")
if raw is not None:
- dims = int(raw)
+ try:
+ dims = int(raw)
+ except ValueError as exc:
+ raise ValueError("EMBEDDING_DIMENSIONS must be an integer.") from exc
- if dims is None:
+ if dims is None:
raise ValueError("EMBEDDING_DIMENSIONS must be set in environment.")
+ if dims <= 0:
+ raise ValueError("EMBEDDING_DIMENSIONS must be a positive integer.")
return dims🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| # Global settings instance | ||
| settings = Settings() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Consider using health-based dependency for reliable startup.
The crawler now requires the database for
pg_store_managerinitialization. Usingdepends_on: - dbonly ensures the container starts, not that PostgreSQL is ready to accept connections. This may cause connection errors during crawler startup.Proposed fix to wait for healthy database
# Dependencies depends_on: - - db + db: + condition: service_healthy📝 Committable suggestion
🤖 Prompt for AI Agents