Fetch available Ollama models.
()
| 617 | @blueprint.route("/models/ollama", methods=["GET"], endpoint='models_ollama') |
| 618 | @pga_login_required |
| 619 | def get_ollama_models(): |
| 620 | """ |
| 621 | Fetch available Ollama models. |
| 622 | """ |
| 623 | from pgadmin.llm.utils import get_ollama_api_url |
| 624 | |
| 625 | api_url = get_ollama_api_url() |
| 626 | if not api_url: |
| 627 | return make_json_response( |
| 628 | data={'models': [], 'error': 'No API URL configured'}, |
| 629 | status=200 |
| 630 | ) |
| 631 | |
| 632 | try: |
| 633 | models = _fetch_ollama_models(api_url) |
| 634 | return make_json_response(data={'models': models}, status=200) |
| 635 | except LLMApiError as e: |
| 636 | return make_json_response( |
| 637 | data={'models': [], 'error': str(e)}, |
| 638 | status=200 |
| 639 | ) |
| 640 | except Exception: |
| 641 | return make_json_response( |
| 642 | data={'models': [], |
| 643 | 'error': 'Failed to fetch Ollama models. ' |
| 644 | 'Check the API URL configuration.'}, |
| 645 | status=200 |
| 646 | ) |
| 647 | |
| 648 | |
| 649 | @blueprint.route( |
nothing calls this directly
no test coverage detected