(prompt: str, use_cache: bool = True)
| 126 | |
| 127 | # By default, we Google Gemini 2.5 pro, as it shows great performance for code understanding |
| 128 | def call_llm(prompt: str, use_cache: bool = True) -> str: |
| 129 | # Log the prompt |
| 130 | logger.info(f"PROMPT: {prompt}") |
| 131 | |
| 132 | # Check cache if enabled |
| 133 | if use_cache: |
| 134 | # Load cache from disk |
| 135 | cache = load_cache() |
| 136 | # Return from cache if exists |
| 137 | if prompt in cache: |
| 138 | logger.info(f"RESPONSE: {cache[prompt]}") |
| 139 | return cache[prompt] |
| 140 | |
| 141 | provider = get_llm_provider() |
| 142 | if provider == "GEMINI": |
| 143 | response_text = _call_llm_gemini(prompt) |
| 144 | else: # generic method using a URL that is OpenAI compatible API (Ollama, ...) |
| 145 | response_text = _call_llm_provider(prompt) |
| 146 | |
| 147 | # Log the response |
| 148 | logger.info(f"RESPONSE: {response_text}") |
| 149 | |
| 150 | # Update cache if enabled |
| 151 | if use_cache: |
| 152 | # Load cache again to avoid overwrites |
| 153 | cache = load_cache() |
| 154 | # Add to cache and save |
| 155 | cache[prompt] = response_text |
| 156 | save_cache(cache) |
| 157 | |
| 158 | return response_text |
| 159 | |
| 160 | |
| 161 | def _call_llm_gemini(prompt: str) -> str: |
no test coverage detected