Skip to content

Commit 1485f3b

Browse files
committed
Expand file types tested with file_search
This expands the file types tested with file_search to include Word documents (.docx), Markdown (.md), text (.txt), PDF (.pdf), and PowerPoint (.pptx) files. Python's mimetypes library doesn't actually recognize markdown docs as text, so we have to handle that case specifically instead of relying on mimetypes to get it right. Signed-off-by: Ben Browning <[email protected]>
1 parent 0f7d487 commit 1485f3b

File tree

7 files changed

+90
-5
lines changed

7 files changed

+90
-5
lines changed

llama_stack/providers/inline/tool_runtime/synthetic-data-kit/synthetic_data_kit.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from typing import Any
1414

1515
from llama_stack.apis.common.content_types import URL
16-
from llama_stack.apis.files.files import Files
16+
from llama_stack.apis.files import Files
1717
from llama_stack.apis.tools import (
1818
ListToolDefsResponse,
1919
ToolDef,
@@ -76,7 +76,7 @@ async def invoke_tool(self, tool_name: str, kwargs: dict[str, Any]) -> ToolInvoc
7676

7777
file_id = kwargs["file_id"]
7878
file_response = await self.files_api.openai_retrieve_file(file_id)
79-
mime_type, _ = mimetypes.guess_type(file_response.filename)
79+
mime_type = self._guess_mime_type(file_response.filename)
8080
content_response = await self.files_api.openai_retrieve_file_content(file_id)
8181

8282
mime_category = mime_type.split("/")[0] if mime_type else None
@@ -89,10 +89,16 @@ async def invoke_tool(self, tool_name: str, kwargs: dict[str, Any]) -> ToolInvoc
8989
)
9090
else:
9191
return await asyncio.to_thread(
92-
self.synthetic_data_kit_convert, content_response.body, file_response.filename
92+
self._synthetic_data_kit_convert, content_response.body, file_response.filename
9393
)
9494

95-
def synthetic_data_kit_convert(self, content_body: bytes, filename: str) -> ToolInvocationResult:
95+
def _guess_mime_type(self, filename: str) -> str | None:
96+
mime_type, _ = mimetypes.guess_type(filename)
97+
if mime_type is None and filename.endswith(".md"):
98+
mime_type = "text/markdown"
99+
return mime_type
100+
101+
def _synthetic_data_kit_convert(self, content_body: bytes, filename: str) -> ToolInvocationResult:
96102
from synthetic_data_kit.core.ingest import process_file
97103

98104
try:
Binary file not shown.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Llama Stack
2+
3+
## Llama Stack Overview
4+
5+
Llama Stack standardizes the core building blocks that simplify AI application development. It codifies best practices across the Llama ecosystem. More specifically, it provides
6+
7+
* Unified API layer for Inference, RAG, Agents, Tools, Safety, Evals, and Telemetry.
8+
9+
* Plugin architecture to support the rich ecosystem of different API implementations in various environments, including local development, on-premises, cloud, and mobile.
10+
11+
* Prepackaged verified distributions which offer a one-stop solution for developers to get started quickly and reliably in any environment.
12+
13+
* Multiple developer interfaces like CLI and SDKs for Python, Typescript, iOS, and Android.
14+
15+
* Standalone applications as examples for how to build production-grade AI applications with Llama Stack.
16+
17+
## Llama Stack Benefits
18+
19+
* Flexible Options: Developers can choose their preferred infrastructure without changing APIs and enjoy flexible deployment choices.
20+
21+
* Consistent Experience: With its unified APIs, Llama Stack makes it easier to build, test, and deploy AI applications with consistent application behavior.
22+
23+
* Robust Ecosystem: Llama Stack is already integrated with distribution partners (cloud providers, hardware vendors, and AI-focused companies) that offer tailored infrastructure, software, and services for deploying Llama models.
24+
25+
# Llama 4 Maverick
26+
27+
Llama 4 Maverick is a Mixture-of-Experts (MoE) model with 17 billion active parameters and 128 experts.
Binary file not shown.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Llama Stack
2+
3+
4+
Llama Stack Overview
5+
6+
Llama Stack standardizes the core building blocks that simplify AI application development. It codifies best practices across the Llama ecosystem. More specifically, it provides
7+
8+
* Unified API layer for Inference, RAG, Agents, Tools, Safety, Evals, and Telemetry.
9+
* Plugin architecture to support the rich ecosystem of different API implementations in various environments, including local development, on-premises, cloud, and mobile.
10+
* Prepackaged verified distributions which offer a one-stop solution for developers to get started quickly and reliably in any environment.
11+
* Multiple developer interfaces like CLI and SDKs for Python, Typescript, iOS, and Android.
12+
* Standalone applications as examples for how to build production-grade AI applications with Llama Stack.
13+
14+
15+
Llama Stack Benefits
16+
17+
* Flexible Options: Developers can choose their preferred infrastructure without changing APIs and enjoy flexible deployment choices.
18+
* Consistent Experience: With its unified APIs, Llama Stack makes it easier to build, test, and deploy AI applications with consistent application behavior.
19+
* Robust Ecosystem: Llama Stack is already integrated with distribution partners (cloud providers, hardware vendors, and AI-focused companies) that offer tailored infrastructure, software, and services for deploying Llama models.
20+
21+
22+
Llama 4 Maverick
23+
24+
Llama 4 Maverick is a Mixture-of-Experts (MoE) model with 17 billion active parameters and 128 experts.

tests/verifications/openai_api/fixtures/test_cases/responses.yaml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,40 @@ test_response_file_search:
4242
# vector_store_ids param for file_search tool gets added by the test runner
4343
file_content: "Llama 4 Maverick has 128 experts"
4444
output: "128"
45+
- case_id: "llama_experts_docx"
46+
input: "How many experts does the Llama 4 Maverick model have?"
47+
tools:
48+
- type: file_search
49+
# vector_store_ids param for file_search toolgets added by the test runner
50+
file_path: "docs/llama_stack_and_models.docx"
51+
output: "128"
52+
- case_id: "llama_experts_md"
53+
input: "How many experts does the Llama 4 Maverick model have?"
54+
tools:
55+
- type: file_search
56+
# vector_store_ids param for file_search toolgets added by the test runner
57+
file_path: "docs/llama_stack_and_models.md"
58+
output: "128"
4559
- case_id: "llama_experts_pdf"
4660
input: "How many experts does the Llama 4 Maverick model have?"
4761
tools:
4862
- type: file_search
4963
# vector_store_ids param for file_search toolgets added by the test runner
50-
file_path: "pdfs/llama_stack_and_models.pdf"
64+
file_path: "docs/llama_stack_and_models.pdf"
65+
output: "128"
66+
- case_id: "llama_experts_pptx"
67+
input: "How many experts does the Llama 4 Maverick model have?"
68+
tools:
69+
- type: file_search
70+
# vector_store_ids param for file_search toolgets added by the test runner
71+
file_path: "docs/llama_stack_and_models.pptx"
72+
output: "128"
73+
- case_id: "llama_experts_txt"
74+
input: "How many experts does the Llama 4 Maverick model have?"
75+
tools:
76+
- type: file_search
77+
# vector_store_ids param for file_search toolgets added by the test runner
78+
file_path: "docs/llama_stack_and_models.txt"
5179
output: "128"
5280

5381
test_response_mcp_tool:

0 commit comments

Comments
 (0)