1 line
2.1 KiB
JSON
1 line
2.1 KiB
JSON
{"repo": "chuanyue98/cuitcca", "files": {"tests/test_llm_predictor.py": {"894ba438dac4df775bdf63b82c426e78d83737dd": {"t": 1785846972.0982003, "n": 1906, "h": "6cbdd8aaa582f41c", "c": "import unittest\nfrom unittest.mock import patch\n\nimport configs.llm_predictor as llm_predictor\nimport configs.load_env as env_config\nfrom llama_index.llms.openai_like import OpenAILike\n\nimport tests._pathsetup # noqa: F401 (adds backend/app to sys.path)\n\n\nclass BuildLlmTest(unittest.TestCase):\n def test_reads_current_env_config_values_at_call_time(self):\n with patch.object(env_config, 'openai_api_key', 'sk-test'), \\\n patch.object(env_config, 'openai_api_base', 'https://example.test/v1'), \\\n patch.object(env_config, 'openai_model', 'sensenova-6.7-flash-lite'):\n llm = llm_predictor.build_llm()\n\n self.assertIsInstance(llm, OpenAILike)\n self.assertEqual(llm.model, 'sensenova-6.7-flash-lite')\n self.assertEqual(llm.api_base, 'https://example.test/v1')\n self.assertEqual(llm.api_key, 'sk-test')\n self.assertTrue(llm.is_chat_model)\n self.assertGreater(llm.context_window, 0)\n\n def test_picks_up_updated_config_on_a_fresh_call(self):\n \"\"\"build_llm must read live config, not a value captured once at import time\n (the existing openai_api_key `from x import y` pattern goes stale after\n /manage/env updates configs.load_env's globals -- build_llm must not repeat that).\"\"\"\n with patch.object(env_config, 'openai_model', 'model-one'):\n llm1 = llm_predictor.build_llm()\n with patch.object(env_config, 'openai_model', 'model-two'):\n llm2 = llm_predictor.build_llm()\n\n self.assertEqual(llm1.model, 'model-one')\n self.assertEqual(llm2.model, 'model-two')\n\n def test_unknown_model_gets_a_safe_default_context_window(self):\n with patch.object(env_config, 'openai_model', 'some-unreleased-model'):\n llm = llm_predictor.build_llm()\n self.assertGreater(llm.context_window, 0)\n\n\nif __name__ == '__main__':\n unittest.main()\n"}}}} |