-
-
Notifications
You must be signed in to change notification settings - Fork 29
Removed the hardcoded Ollama Models and now works with any Ollama Model #385
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
base: main
Are you sure you want to change the base?
Changes from all commits
4fab76a
565062e
a940c87
370f6df
88b2f6e
a88fe76
e898546
607d880
751edb8
0d058db
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 |
|---|---|---|
|
|
@@ -240,8 +240,31 @@ def test_default_model_claude(self): | |
|
|
||
| def test_default_model_ollama(self): | ||
| """Test default model for Ollama.""" | ||
| # Test with environment variable | ||
|
|
||
| # Save and clear any existing OLLAMA_MODEL | ||
| original_model = os.environ.get("OLLAMA_MODEL") | ||
|
|
||
| # Test with custom env variable | ||
| os.environ["OLLAMA_MODEL"] = "test-model" | ||
| handler = AskHandler(api_key="test", provider="ollama") | ||
| self.assertEqual(handler.model, "llama3.2") | ||
| self.assertEqual(handler.model, "test-model") | ||
|
|
||
| # Clean up | ||
| if original_model is not None: | ||
| os.environ["OLLAMA_MODEL"] = original_model | ||
| else: | ||
| os.environ.pop("OLLAMA_MODEL", None) | ||
|
|
||
| # Test deterministic default behavior when no env var or config file exists. | ||
| # Point the home directory to a temporary location without ~/.cortex/config.json | ||
| with ( | ||
| tempfile.TemporaryDirectory() as tmpdir, | ||
| patch("os.path.expanduser", return_value=tmpdir), | ||
| ): | ||
|
Comment on lines
+261
to
+264
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. Critical: Wrong patch target breaks test isolation. Line 263 patches config_file = Path.home() / ".cortex" / "config.json"Patching 🔎 Proposed fix+ from pathlib import Path
+
# Test deterministic default behavior when no env var or config file exists.
# Point the home directory to a temporary location without ~/.cortex/config.json
with (
tempfile.TemporaryDirectory() as tmpdir,
- patch("os.path.expanduser", return_value=tmpdir),
+ patch("pathlib.Path.home", return_value=Path(tmpdir)),
):
handler2 = AskHandler(api_key="test", provider="ollama")
# When no env var and no config file exist, AskHandler should use its built-in default.
self.assertEqual(handler2.model, "llama3.2")🤖 Prompt for AI Agents |
||
| handler2 = AskHandler(api_key="test", provider="ollama") | ||
| # When no env var and no config file exist, AskHandler should use its built-in default. | ||
| self.assertEqual(handler2.model, "llama3.2") | ||
|
|
||
| def test_default_model_fake(self): | ||
| """Test default model for fake provider.""" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.