Skip to content

Conversation

@onmete
Copy link
Contributor

@onmete onmete commented Jun 26, 2025

Description

Add LLM check in readiness endpoint

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement

Related Tickets & Documents

  • Related Issue #
  • Closes #

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

return False

logger.debug("LLM connection verified - found %d LLM models", len(llm_models))
return True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this should call the LLM provider's client.providers.retrieve function to actually test the LLM.

https://github.com/ansible/ansible-ai-connect-service/blob/main/ansible_ai_connect/ai/api/model_pipelines/llamastack/pipelines.py#L152-L162

This simply returns True if some LLM models have been registered; not that they actually work.

return False


def index_is_ready() -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get the list of available models from the configured LlamaStack client.
"""
try:
from client import get_llama_stack_client
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not to import at top?

client = get_llama_stack_client(llama_stack_config)

# Try to list models to verify LLM connection
models = client.models.list()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this just list the models, not doing any connection check. It works even when I turned off my WiFi (and the model is remote).

logger.warning("No LLM models found in available models")
return False

logger.debug("LLM connection verified - found %d LLM models", len(llm_models))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You haven't verified a connection only that there are more than zero LLMs registered.

try:
llama_stack_config = configuration.llama_stack_configuration

# TODO: this seems to be an expensive operation (takes 1-2 seconds)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #122

args = parser.parse_args()

configuration.load_configuration("lightspeed-stack.yaml")
configuration.load_configuration(args.config_file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay. Finally I won't need to tweak the code 😘

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that should be a separate PR. Let me raise it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already did :D. I'll just rebase here.

Copy link
Contributor

@manstis manstis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@tisnik can have the final say.

@onmete
Copy link
Contributor Author

onmete commented Jun 30, 2025

@tisnik fixed linting

Copy link
Contributor

@tisnik tisnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@tisnik tisnik merged commit 730e4cf into lightspeed-core:main Jul 1, 2025
18 checks passed
@TamiTakamiya TamiTakamiya mentioned this pull request Jul 29, 2025
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants