-
Notifications
You must be signed in to change notification settings - Fork 26
Fix/ollama setup and stability #125
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
Changes from all commits
ef902e4
a671926
cf7cc23
66dc268
f0d4c7a
5636055
ddd8a11
de1bc4b
91e5cee
4567e22
69fa704
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| class LLMProvider(Enum): | ||
| """Supported LLM providers.""" | ||
| OPENAI = "openai" | ||
| OLLAMA = "ollama" | ||
| CUSTOM = "custom" | ||
|
|
||
|
|
||
|
|
@@ -72,6 +73,7 @@ def create_ollama_config( | |
| ) -> Dict[str, Any]: | ||
| """Create Ollama configuration.""" | ||
| return { | ||
| "api_key": "dummy", # Ollama doesn't require an API key | ||
| "base_url": base_url, | ||
| "model": model, | ||
| "embedding_model": embedding_model, | ||
|
|
@@ -146,10 +148,15 @@ def build_memory_config_from_env() -> MemoryConfig: | |
| memory_config = config_loader.get_memory_extraction_config() | ||
|
|
||
| # Get LLM provider from environment | ||
| llm_provider = os.getenv("LLM_PROVIDER", "openai").lower() | ||
| if llm_provider not in ["openai"]: | ||
| llm_provider = os.getenv("LLM_PROVIDER", "openai").lower().strip() | ||
| memory_logger.info(f"LLM_PROVIDER: {llm_provider}") | ||
| if llm_provider not in [p.value for p in LLMProvider]: | ||
| raise ValueError(f"Unsupported LLM provider: {llm_provider}") | ||
|
|
||
| llm_config = None | ||
| llm_provider_enum = None | ||
| embedding_dims = 1536 # Default | ||
|
|
||
| # Build LLM configuration | ||
| if llm_provider == "openai": | ||
| openai_api_key = os.getenv("OPENAI_API_KEY") | ||
|
|
@@ -182,7 +189,28 @@ def build_memory_config_from_env() -> MemoryConfig: | |
| else: | ||
| # Default for OpenAI embedding models | ||
| embedding_dims = 1536 | ||
|
|
||
| elif llm_provider == "ollama": | ||
| base_url = os.getenv("OLLAMA_BASE_URL") | ||
| if not base_url: | ||
| raise ValueError("OLLAMA_BASE_URL required for Ollama provider") | ||
|
|
||
| model = os.getenv("OLLAMA_MODEL") | ||
| if not model: | ||
| raise ValueError("OLLAMA_MODEL required for Ollama provider") | ||
| embedding_model = os.getenv("OLLAMA_EMBEDDER_MODEL") | ||
| if not embedding_model: | ||
| raise ValueError("OLLAMA_EMBEDDER_MODEL required for Ollama provider") | ||
| memory_logger.info(f"🔧 Memory config: LLM={model}, Embedding={embedding_model}, Base URL={base_url}") | ||
|
|
||
| llm_config = create_ollama_config( | ||
| base_url=base_url, | ||
| model=model, | ||
| embedding_model=embedding_model, | ||
| ) | ||
| llm_provider_enum = LLMProvider.OLLAMA | ||
| embedding_dims = 768 # For nomic-embed-text | ||
|
|
||
|
Comment on lines
+212
to
+213
Contributor
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. Hardcoded Ollama embedding dims (768) will break with non‑nomic models Vector DB dims must match the embedder. If users set a different embedder (e.g., 384/1024), Qdrant ops will fail. Apply: - embedding_dims = 768 # For nomic-embed-text
+ # Default for nomic-embed-text; allow override for other embedders
+ embedding_dims = int(os.getenv("OLLAMA_EMBEDDING_DIMS", "768"))Also log the final dims to aid debugging. Consider probing dims once (generate 1 embedding) and create the collection accordingly, or read from config. 🤖 Prompt for AI Agents |
||
| # Build vector store configuration | ||
| vector_store_provider = os.getenv("VECTOR_STORE_PROVIDER", "qdrant").lower() | ||
|
|
||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
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.
🧩 Analysis chain
MongoDB healthcheck command is invalid; will never become healthy
db.runCommand('ping')is not valid; use{ ping: 1 }. If this never passes, services depending onservice_healthywill stall.Apply:
If the
mongo:8.0.14image lacksmongosh, switch tomongodb/mongodb-community-serveror install the shell.I'll verify the MongoDB healthcheck syntax claims by searching for the correct mongosh documentation and container image details.
🌐 Web query:
💡 Result:
Short answer — use db.runCommand({ ping: 1 }) and check the returned ok field. Example usages:
In mongosh interactive:
db.runCommand({ ping: 1 })
// returns a document with ok: 1 on success. [1][2]
As a noninteractive healthcheck (Docker / scripts) using mongosh --quiet:
echo 'db.runCommand({ping:1}).ok' | mongosh localhost:27017/mydb --quiet
returns "1" when healthy. Use localhost or the container host name as appropriate. [2][3]
Notes:
Sources: MongoDB ping command and db.runCommand docs; examples from community Docker health-check threads. [1][2][3]
🌐 Web query:
💡 Result:
Short answer: Yes — the official MongoDB Docker images for the 8.0 line include mongosh (the modern shell). See MongoDB docs/listing of bundled tools (mongosh listed for the community/enterprise images) and the 8.0 release notes. [1][2][3]
Sources:
If you want I can show how to verify inside a container (docker run + which mongosh / mongosh --version).
MongoDB healthcheck command is invalid; will never become healthy
db.runCommand('ping')is not valid syntax; must be an object like{ ping: 1 }. Since the health check will fail, services depending onservice_healthywill stall.Apply:
📝 Committable suggestion
🤖 Prompt for AI Agents
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.
I have made the changes
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.
🧩 Analysis chain
🏁 Script executed:
Length of output: 220
@RKRitik Perfect! The MongoDB healthcheck is now correctly configured with
db.adminCommand({ ping: 1 })and the--quietflag. This will properly report health status and prevent dependent services from stalling. Great work! 🎉If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!