llama-stack-mirror/llama_stack/providers/inline
Ben Browning 655d3d0466 fix: annotations list and web_search_preview in Responses
These are a couple of fixes to get an example LangChain app working
with our OpenAI Responses API implementation.

The Responses API spec requires an annotations array in
output[*].content[*].annotations and we were not providing one. So,
this adds that as an empty list, even though we don't do anything to
populate it yet. This prevents an error from client libraries like
Langchain that expect this field to always exist, even if an empty
list.

The other fix is `web_search_preview` is a valid name for the web
search tool in the Responses API, but we only responded to
`web_search` or `web_search_preview_2025_03_11`.

The existing Responses unit tests were expanded to test these cases,
via:

```
pytest -sv tests/unit/providers/agents/meta_reference/test_openai_responses.py
```

The existing test_openai_responses.py integration tests still pass
with this change, tested as below with Fireworks:

```
uv run llama stack run llama_stack/templates/starter/run.yaml

LLAMA_STACK_CONFIG=http://localhost:8321 \
uv run pytest -sv tests/integration/agents/test_openai_responses.py \
  --text-model accounts/fireworks/models/llama4-scout-instruct-basic
```

Lastly, this example Langchain app now works with Llama stack (tested
with Ollama in the starter template in this case):

```python
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    base_url="http://localhost:8321/v1/openai/v1",
    api_key="fake",
    model="ollama/meta-llama/Llama-3.2-3B-Instruct",
)

tool = {"type": "web_search_preview"}
llm_with_tools = llm.bind_tools([tool])

response = llm_with_tools.invoke("What was a positive news story from today?")

print(response.content)
```

Signed-off-by: Ben Browning <bbrownin@redhat.com>
2025-06-25 15:14:10 -04:00
..
agents fix: annotations list and web_search_preview in Responses 2025-06-25 15:14:10 -04:00
datasetio chore(refact): move paginate_records fn outside of datasetio (#2137) 2025-05-12 10:56:14 -07:00
eval feat: implementation for agent/session list and describe (#1606) 2025-05-07 14:49:23 +02:00
files/localfs feat: support pagination in inference/responses stores (#2397) 2025-06-16 22:43:35 -07:00
inference feat: New OpenAI compat embeddings API (#2314) 2025-05-31 22:11:47 -07:00
ios/inference chore: removed executorch submodule (#1265) 2025-02-25 21:57:21 -08:00
post_training ci: add python package build test (#2457) 2025-06-19 18:57:32 +05:30
safety feat: add cpu/cuda config for prompt guard (#2194) 2025-05-28 12:23:15 -07:00
scoring ci: add python package build test (#2457) 2025-06-19 18:57:32 +05:30
telemetry feat: drop python 3.10 support (#2469) 2025-06-19 12:07:14 +05:30
tool_runtime feat: Implement hybrid search in SQLite-vec (#2312) 2025-06-13 15:54:06 -04:00
vector_io feat: Add missing Vector Store Files API surface (#2468) 2025-06-19 11:08:24 -04:00
__init__.py impls -> inline, adapters -> remote (#381) 2024-11-06 14:54:05 -08:00