mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-13 04:22:35 +00:00
update test
This commit is contained in:
parent
571276f88c
commit
b563835a82
5 changed files with 5490 additions and 29 deletions
|
|
@ -0,0 +1,203 @@
|
||||||
|
{
|
||||||
|
"test_id": "tests/integration/tool_runtime/test_mcp.py::test_mcp_invocation[txt=ollama/llama3.2:3b-instruct-fp16]",
|
||||||
|
"request": {
|
||||||
|
"method": "POST",
|
||||||
|
"url": "http://0.0.0.0:11434/v1/v1/chat/completions",
|
||||||
|
"headers": {},
|
||||||
|
"body": {
|
||||||
|
"model": "llama3.2:3b-instruct-fp16",
|
||||||
|
"messages": [
|
||||||
|
{
|
||||||
|
"role": "system",
|
||||||
|
"content": "You are a helpful assistant."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": [
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"text": "Say hi to the world. Use tools to do so."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"role": "assistant",
|
||||||
|
"content": "",
|
||||||
|
"tool_calls": [
|
||||||
|
{
|
||||||
|
"index": 0,
|
||||||
|
"id": "call_c1tlwvxc",
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
|
"name": "greet_everyone",
|
||||||
|
"arguments": "{\"url\":\"world\"}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"role": "tool",
|
||||||
|
"tool_call_id": "call_c1tlwvxc",
|
||||||
|
"content": [
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"text": "Hello, world!"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"role": "assistant",
|
||||||
|
"content": "I apologize, it seems like my previous response from the tool did not translate to a clear greeting.\n\nLet me try again using a different approach. I can use a text-to-speech conversion tool to say hello in various languages:\n\n\"Hello\"\n\n(or)\n\n\"Pong\"\n\n(in multiple languages such as Spanish: \"Hola\", French: \"Bonjour\", Chinese:, Japanese:, Korean:, or many others)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": [
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"text": "What is the boiling point of polyjuice? Use tools to answer."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stream": true,
|
||||||
|
"stream_options": {
|
||||||
|
"include_usage": true
|
||||||
|
},
|
||||||
|
"tools": [
|
||||||
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
|
"name": "greet_everyone",
|
||||||
|
"parameters": {
|
||||||
|
"properties": {
|
||||||
|
"url": {
|
||||||
|
"title": "Url",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"url"
|
||||||
|
],
|
||||||
|
"title": "greet_everyoneArguments",
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
|
"name": "get_boiling_point",
|
||||||
|
"description": "\n Returns the boiling point of a liquid in Celsius or Fahrenheit.\n\n :param liquid_name: The name of the liquid\n :param celsius: Whether to return the boiling point in Celsius\n :return: The boiling point of the liquid in Celcius or Fahrenheit\n ",
|
||||||
|
"parameters": {
|
||||||
|
"properties": {
|
||||||
|
"liquid_name": {
|
||||||
|
"title": "Liquid Name",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"celsius": {
|
||||||
|
"default": true,
|
||||||
|
"title": "Celsius",
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"liquid_name"
|
||||||
|
],
|
||||||
|
"title": "get_boiling_pointArguments",
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"endpoint": "/v1/chat/completions",
|
||||||
|
"model": "llama3.2:3b-instruct-fp16"
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"__type__": "openai.types.chat.chat_completion_chunk.ChatCompletionChunk",
|
||||||
|
"__data__": {
|
||||||
|
"id": "rec-0b29d8fc2fee",
|
||||||
|
"choices": [
|
||||||
|
{
|
||||||
|
"delta": {
|
||||||
|
"content": "",
|
||||||
|
"function_call": null,
|
||||||
|
"refusal": null,
|
||||||
|
"role": "assistant",
|
||||||
|
"tool_calls": [
|
||||||
|
{
|
||||||
|
"index": 0,
|
||||||
|
"id": "call_h8atvnz3",
|
||||||
|
"function": {
|
||||||
|
"arguments": "{\"celsius\":\"true\",\"liquid_name\":\"polyjuice\"}",
|
||||||
|
"name": "get_boiling_point"
|
||||||
|
},
|
||||||
|
"type": "function"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"finish_reason": null,
|
||||||
|
"index": 0,
|
||||||
|
"logprobs": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"created": 0,
|
||||||
|
"model": "llama3.2:3b-instruct-fp16",
|
||||||
|
"object": "chat.completion.chunk",
|
||||||
|
"service_tier": null,
|
||||||
|
"system_fingerprint": "fp_ollama",
|
||||||
|
"usage": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "openai.types.chat.chat_completion_chunk.ChatCompletionChunk",
|
||||||
|
"__data__": {
|
||||||
|
"id": "rec-0b29d8fc2fee",
|
||||||
|
"choices": [
|
||||||
|
{
|
||||||
|
"delta": {
|
||||||
|
"content": "",
|
||||||
|
"function_call": null,
|
||||||
|
"refusal": null,
|
||||||
|
"role": "assistant",
|
||||||
|
"tool_calls": null
|
||||||
|
},
|
||||||
|
"finish_reason": "tool_calls",
|
||||||
|
"index": 0,
|
||||||
|
"logprobs": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"created": 0,
|
||||||
|
"model": "llama3.2:3b-instruct-fp16",
|
||||||
|
"object": "chat.completion.chunk",
|
||||||
|
"service_tier": null,
|
||||||
|
"system_fingerprint": "fp_ollama",
|
||||||
|
"usage": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "openai.types.chat.chat_completion_chunk.ChatCompletionChunk",
|
||||||
|
"__data__": {
|
||||||
|
"id": "rec-0b29d8fc2fee",
|
||||||
|
"choices": [],
|
||||||
|
"created": 0,
|
||||||
|
"model": "llama3.2:3b-instruct-fp16",
|
||||||
|
"object": "chat.completion.chunk",
|
||||||
|
"service_tier": null,
|
||||||
|
"system_fingerprint": "fp_ollama",
|
||||||
|
"usage": {
|
||||||
|
"completion_tokens": 29,
|
||||||
|
"prompt_tokens": 414,
|
||||||
|
"total_tokens": 443,
|
||||||
|
"completion_tokens_details": null,
|
||||||
|
"prompt_tokens_details": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"is_streaming": true
|
||||||
|
},
|
||||||
|
"id_normalization_mapping": {}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -91,7 +91,7 @@
|
||||||
"tool_calls": [
|
"tool_calls": [
|
||||||
{
|
{
|
||||||
"index": 0,
|
"index": 0,
|
||||||
"id": "call_j1l3nnv3",
|
"id": "call_c1tlwvxc",
|
||||||
"function": {
|
"function": {
|
||||||
"arguments": "{\"url\":\"world\"}",
|
"arguments": "{\"url\":\"world\"}",
|
||||||
"name": "greet_everyone"
|
"name": "greet_everyone"
|
||||||
|
|
|
||||||
|
|
@ -132,31 +132,3 @@ def test_mcp_invocation(llama_stack_client, text_model_id, mcp_server):
|
||||||
assert tool_events[-1].result.tool_calls[0].tool_name == "greet_everyone"
|
assert tool_events[-1].result.tool_calls[0].tool_name == "greet_everyone"
|
||||||
|
|
||||||
assert "hello" in final_response.output_text.lower()
|
assert "hello" in final_response.output_text.lower()
|
||||||
|
|
||||||
# when streaming, we currently don't check auth headers upfront and fail the request
|
|
||||||
# early. but we should at least be generating a 401 later in the process.
|
|
||||||
response_stream = agent.create_turn(
|
|
||||||
session_id=session_id,
|
|
||||||
messages=[
|
|
||||||
{
|
|
||||||
"type": "message",
|
|
||||||
"role": "user",
|
|
||||||
"content": [
|
|
||||||
{
|
|
||||||
"type": "input_text",
|
|
||||||
"text": "What is the boiling point of polyjuice? Use tools to answer.",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
}
|
|
||||||
],
|
|
||||||
stream=True,
|
|
||||||
)
|
|
||||||
if isinstance(llama_stack_client, LlamaStackAsLibraryClient):
|
|
||||||
with pytest.raises(AuthenticationRequiredError):
|
|
||||||
for _ in response_stream:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
error_chunks = [chunk for chunk in response_stream if "error" in chunk.model_dump()]
|
|
||||||
assert len(error_chunks) == 1
|
|
||||||
chunk = error_chunks[0].model_dump()
|
|
||||||
assert "Unauthorized" in chunk["error"]["message"]
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue