Skip to content
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

feat: completing text /chat-completion and /completion tests #1223

Merged
merged 1 commit into from
Feb 25, 2025

Conversation

LESSuseLESS
Copy link
Contributor

What does this PR do?

The goal is to have a fairly complete set of provider and e2e tests for /chat-completion and /completion. This is the current list,

grep -oE "def test_[a-zA-Z_+]*" llama_stack/providers/tests/inference/test_text_inference.py | cut -d' ' -f2
  • test_model_list
  • test_text_completion_non_streaming
  • test_text_completion_streaming
  • test_text_completion_logprobs_non_streaming
  • test_text_completion_logprobs_streaming
  • test_text_completion_structured_output
  • test_text_chat_completion_non_streaming
  • test_text_chat_completion_structured_output
  • test_text_chat_completion_streaming
  • test_text_chat_completion_with_tool_calling
  • test_text_chat_completion_with_tool_calling_streaming
grep -oE "def test_[a-zA-Z_+]*" tests/client-sdk/inference/test_text_inference.py | cut -d' ' -f2
  • test_text_completion_non_streaming
  • test_text_completion_streaming
  • test_text_completion_log_probs_non_streaming
  • test_text_completion_log_probs_streaming
  • test_text_completion_structured_output
  • test_text_chat_completion_non_streaming
  • test_text_chat_completion_streaming
  • test_text_chat_completion_with_tool_calling_and_non_streaming
  • test_text_chat_completion_with_tool_calling_and_streaming
  • test_text_chat_completion_with_tool_choice_required
  • test_text_chat_completion_with_tool_choice_none
  • test_text_chat_completion_structured_output
  • test_text_chat_completion_tool_calling_tools_not_in_request

Test plan

== Set up Ollama local server

OLLAMA_HOST=127.0.0.1:8321 with-proxy ollama serve
OLLAMA_HOST=127.0.0.1:8321 ollama run llama3.2:3b-instruct-fp16 --keepalive 60m

== Run a provider test

conda activate stack
OLLAMA_URL="http://localhost:8321" \
pytest -v -s -k "ollama" --inference-model="llama3.2:3b-instruct-fp16" \
llama_stack/providers/tests/inference/test_text_inference.py::TestInference

== Run an e2e test

conda activate sherpa
with-proxy pip install llama-stack
export INFERENCE_MODEL=llama3.2:3b-instruct-fp16
export LLAMA_STACK_PORT=8322
with-proxy llama stack build --template ollama
with-proxy llama stack run --env OLLAMA_URL=http://localhost:8321 ollama
conda activate stack
LLAMA_STACK_PORT=8322 LLAMA_STACK_BASE_URL="http://localhost:8322" \
pytest -v -s --inference-model="llama3.2:3b-instruct-fp16" \
tests/client-sdk/inference/test_text_inference.py

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Feb 23, 2025
@LESSuseLESS LESSuseLESS changed the title "feat: completing text /chat-completion and /completion tests feat: completing text /chat-completion and /completion tests Feb 23, 2025
@ashwinb
Copy link
Contributor

ashwinb commented Feb 24, 2025

lgtm. cc @hardikjshah @ehhuang to take one look given you have been in the test world lately.

Copy link
Contributor

@hardikjshah hardikjshah left a comment

Choose a reason for hiding this comment

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

left a couple of small comments

@@ -0,0 +1,171 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please update the MANIFEST.in to include these files and remove the deleted ones ? https://github.com/meta-llama/llama-stack/blob/main/MANIFEST.in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, didn't know this before. fixed.

):
# TODO: more dynamic lookup on tool_prompt_format for model family
tool_prompt_format = "json" if "3.1" in text_model_id else "python_list"
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets just drop this as we recently added (https://github.com/meta-llama/llama-stack/pull/1214/files) defaults to be inferred based on model-id at the api level when not provided.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let me fix this with a new diff, so that i can keep this one iso-transformation without any coding logic change

def test_text_chat_completion_with_tool_calling_and_non_streaming(
client_with_models, text_model_id, get_weather_tool_definition, provider_tool_format
client_with_models, text_model_id, provider_tool_format, test_case
Copy link
Contributor

Choose a reason for hiding this comment

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

provider_tool_format does not seem to be used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same here, there are several places that need some cleanup, and I'll fix them with one more diff, instead of this one

@LESSuseLESS LESSuseLESS merged commit 3a31611 into main Feb 25, 2025
3 checks passed
@LESSuseLESS LESSuseLESS deleted the llama_stack_hzhao_pr branch February 25, 2025 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants